Features Releases

PHP CS Fixer Support

PhpStorm already supports the popular code quality checking tools, PHPCS and PHPMD, which help you follow industry coding style standards (such as PSR-2), framework-specific standards, or your own team standards.

Checking for standards compliance is great, but fixing issues by hand can be tedious, especially on large projects. Well, there’s a tool for that, – PHP CS Fixer, – not only does it detect issues, but it will also fix them for you. PhpStorm 2018.3 brings in streamlined support for PHP CS Fixer!

To set up PHP CS Fixer in PhpStorm, all you need to do is modify your composer.json, just as you would do for other code quality tools:

  • Add the friendsofphp/php-cs-fixer as a dev dependency
  • Optionally, provide the custom ruleset in the scripts section.


Then, run Install: PhpStorm will install the necessary packages, detect the path to PHP CS Fixer, and automatically set it up in Settings/Preferences. What’s more, your custom ruleset will also be detected, and the corresponding inspection will be enabled automatically, which can be found under Settings/Preferences | Editor | Inspections | PHP | Quality Tools, just like it would be for PHPCS and PHPMD:


That’s it, you are now good to go; you can now check your files and fix issues on the fly! Note that currently, due to PHP CS Fixer limitations, your only option is to apply the fix for the whole file, rather than fixing individual issues.

PHP CS Fixer fix file

PHP CS Fixer in PhpStorm supports remote interpreters, too, so you can use one of the many Docker images available online with PHP CS Fixer. Some additional setup may be required in this case though, so refer to PhpStorm help should you need assistance.

Your JetBrains PhpStorm Team
The Drive to Develop

image description