composer require symplify/console-color-diff
Add to config/bundles.php
:
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\ConsoleColorDiff\ValueObject\ConsoleColorDiffConfig;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(ConsoleColorDiffConfig::FILE_PATH);
};
namespace App;
use Symplify\ConsoleColorDiff\Console\Output\ConsoleDiffer;
class SomeCommand
{
/**
* @var ConsoleDiffer
*/
private $consoleDiffer;
public function __construct(ConsoleDiffer $consoleDiffer)
{
$this->consoleDiffer = $consoleDiffer;
}
public function run(): void
{
// prints colored diff to the console output
$this->consoleDiffer->diff('oldContent', 'newContent');
}
}
In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker
The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.