Using the TYPO3/FLOW3 Coding Guidlines with PHPStorm and PHP_CodeSniffer (Windows)

By | 25/04/2012

With the new release of PHPStorm 4 there is a CodeSniffer integrated. Since for us TYPO3 developers it doesn’t make much sense to us another coding standard than our own, here a short how-to for the usage of the TYPO3 Coding Guidlines in PHPStorm.

First thing, you have to install PHP and PHP_CodeSniffer on your machine. I had trouble with the CodeSniffer after installing it in C:\Programs (X86) so after uninstalling everything and installing it in C:\PHP the CodeSniffer started to work. Before you enter something in your IDE, verify that your CodeSniffer works by running

The expected result should be:

Next thing is to install the guidelines for TYPO3. For that, clone the repository on git.typo3.org to get the right standards:

Now copy the folders FLOW3, TYPO3, TYPO3v4 to (in my example):

Update:

Another option is to get the TYPO3 Standards from pear.typo3.org. (Thx @ctrabold for the hint)

Open PHPStorm and go to the settings. Settings->Inspections

Select the path to the phpcs.bat file and click “Validate”. If everything works fine you should be able to select a Coding standard in the select box below.

Update:

If you work with TYPO3, select TYPO3v4, if you work with FLOW3, select the FLOW3 Standard. The TYPO3 folder contains the common Codesniffs.

Links:

TYPO3 Codesniffer page on forge: http://forge.typo3.org/projects/team-php_codesniffer/wiki/Using_the_TYPO3_Coding_Standard

PHP_CodeSniffer package on pear: http://pear.php.net/package/PHP_CodeSniffer/

PHP Download for Windows: http://windows.php.net/download/

PHP Codesniffer on forge: http://forge.typo3.org/projects/team-php_codesniffer/wiki/Folder_structure

And now: Have fun writing clean and good code 😉