A Tool that helps you to Migrate to ECS

Found a typo? Edit me
This post is deprecated since June 2021. Its knowledge is old and should not be used.
Why?

This package didn't get much traction since it was introduced and was deprecated.
Use migration post from PHP_CodeSniffer or from PHP-CS-Fixer instead.


Do you want to use ECS but still stuck on an older coding standard tool? I wrote a post how to migrate from PHP_CodeSniffer and from PHP-CS-Fixer.

But who has time to read the step-by-step manual and do manual work? Nobody. That's why today, we'll look at a tool that will handle the migration to ECS for you.

More and more projects I worked with wanted to try ECS, but they didn't want to look at every rule in XML and write them in PHP. I helped the first 3 to do manually and guide them on differences in configuration and rule naming. It was daunting work.

Are you interested in what way is ECS better? Check the mentioned posts:


When I was about to migrate 4th phpcs.xml, I didn't want to repeat copy-pasting, adding fully qualified names from dots, and so on. Some of you know from GitHub Stars profile, that this physically hurts me more than most people.

Luckily, I had to go the toilet. Suddenly I realized:

"If I can do it, so can PHP tool"

That's how Sniffer/Fixer to ECS Converter was born. The tool does what its name says.

2 Steps to Migrate Your Config

  1. Install the package
composer require symplify/sniffer-fixer-to-ecs-converter --dev
  1. Run the convert command

Migrate PHP_CodeSniffer config

vendor/bin/sniffer-fixer-to-ecs-converter convert phpcs.xml

Migrate PHP-CS-Fixer config

vendor/bin/sniffer-fixer-to-ecs-converter convert .php_cs.dist

In both cases, a new config converted-ecs.php was created.


Now you can verify the config by running ECS.

composer require symplify/easy-coding-standard --dev
vendor/bin/ecs check --config converted-ecs.php

If all is good, rename this config to ecs.php and remove your old config + tool from composer.json. Then you're ready to go.

That's it!


Happy coding!


Have you find this post useful? Do you want more?

Follow me on Twitter, RSS or support me on GitHub Sponsors.