Quantcast
Channel: layh.com - Blog » Web development
Viewing all articles
Browse latest Browse all 13

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

$
0
0

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

phpcs.bat --version

The expected result should be:

PHP_CodeSniffer version 1.3.3 (stable) by Squiz Pty Ltd. (http://www.squiz.net)

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

git clone git://git.typo3.org/Teams/forge.typo3.org/hudson-helpers/tools/PHP_CodeSniffer.git

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

C:\PHP\PEAR\PHP\CodeSniffer\Standards

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

PHP CodeSniffer 300x137 Using the TYPO3/FLOW3 Coding Guidlines with PHPStorm and PHP CodeSniffer (Windows)

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 icon wink Using the TYPO3/FLOW3 Coding Guidlines with PHPStorm and PHP CodeSniffer (Windows)

flattr this!


Viewing all articles
Browse latest Browse all 13

Trending Articles