Thursday, December 25, 2008

PHP Codesniffer standard for Symfony


I have created a standard for Symfony framework to use with PHP code sniffer.

-Download and install PHP code sniffer
http://pear.php.net/package/PHP_CodeSniffer

-Check out the code from subversion
http://subversion.assembla.com/svn/phpsymfony/Symfony%20Code%20sniffer%20standards

-Copy the Symfony directory to the code sniffer standard directory

-Put --standard=Symfony for validating the file using Symfony coding standards

$ phpcs --standard=Symfony /path/to/code/myfile.php



2 comments:

bicou said...

Hi, smfony coding guidelines indicate a indent level of 2 spaces, this is a patch :

http://blog.bicou.com/2009/03/symfony-2-space-indent.html

Nico said...

Hello,

I am thinking of using your code sniffer to sniff my Symfony code.

But I did noticed that in :
- ValidClassNameSniff.php
you are specifying :
- class and interface names start with a capital letter.

As far as Symfony doesnt verify this rule (a lot of Symfony classes start with the 'sf' prefix) :
- is your codesniffer in full accordance with Symfony ?

Thank you