New in Symplify 9: Markdown Diff

When we maintain a package docs or generate documentation in Markdown, we write a code snippet from time to time. The clearest way to show what you exactly mean is a diff. That's why diff is used in GitHub commit suggestions.

"Diff is worth 100 code-review words."

But creating automated diff in Markdown is a pickle. We picked the pickle and turned it into a package - symplify/markdown-diff package.

The package does exactly what it says and is mostly used in symplify/rule-doc-generator. I'd say this is the smallest package on Symplify.

3 step to Markdown Diff

  1. Install Package
composer require symplify/markdown-diff
  1. Register in config/bundles.php
use Symplify\MarkdownDiff\Bundle\MarkdownDiffBundle;

return [
    MarkdownDiffBundle::class => [
        'all' => true,
  1. Use it
namespace App;

use Symplify\MarkdownDiff\Differ\MarkdownDiffer;

final class SomeClass
     * @var MarkdownDiffer
    private $markdownDiffer;

    public function __construct(MarkdownDiffer $markdownDiffer)
        $this->markdownDiffer = $markdownDiffer;

    public function run(): void
        $markdownDiff = $this->markdownDiffer->diff('oldContent', 'newContent');

        // ...

        file_put_contents(getcwd() . '/docs/', $markdownDiff);


Pretty simple, right?

Smarter than Normal

Compared to sebastian/diff it builds on, this package does an extra cleaning job:

That's all for today.

Happy coding!

Do you learn from my contents or use open-souce packages like Rector every day?
Consider supporting it on GitHub Sponsors. I'd really appreciate it!