Symfony2: Coding Standards Update

I posted about coding standards in Symfony2 and how to check them a while ago. Since then the standard used has changed as Symfony2 has adopted the PSR 0,1,2 standards. This is just a very quick post to update my earlier post since some of the information in it is now out of date.

Checking these standards will be one of the standards bundled with PHPCodeSniffer although work is still continuing on this at the moment. You can get the work in progress if you get PHPCodeSniffer from github instead of installing it using Pear. Once this is complete there will be no need to install a custom standard in order to check that your Symfony2 project code meets these standards, you can just run /path/to/phpcs --standard=PSR2. Using PSR2 as the standard will automatically check PSR1 and 0 as well as they are subsets of PSR2.

As well as just checking the standards, you can now also use Fabien Potencier’s coding standards fixer, which not just checks but fixes code to meet these standards where possible making fixing it a much less tedious process.