- Install phpcs:
pear install PHP_CodeSniffer
- Find your PEAR directory:
pear config-show | grep php_dir
- Copy, symlink or check out this repo to a folder called Symfony2 inside the
phpcs
Standards
directory:
cd /path/to/pear/PHP/CodeSniffer/Standards
git clone git://github.com/opensky/Symfony2-coding-standard.git Symfony2
-
Do the same for this standard ( Abstrus ).
-
Set Abstrus as your default coding standard:
phpcs --config-set default_standard Abstrus
- Make sure the standard is correctly installed
phpcs -i
- Profit!
cd /path/to/my/project
phpcs
phpcs path/to/my/file.php
-
Open the project settings: File -> Settings (on PC) PhpStorm -> Preferences (on mac)
-
Click Code Sniffer
-
Enter the the path of the Code Sniffer executable or select it using the lick the Browse button.
-
Click the Validate button to check if the Code Sniffer is compatible with your editor.
-
Select your coding standard from the combo box.
-
Don't check the Ignore warning box !
-
Joy !
See a good plugin here.
-
Download the
.vim
file from here -
Copy it to
~/.vim/plugin
-
Set the coding standard to follow in your
~/.vimrc
:
let g:phpcs_std_list="Abstrus"
- Set the max output line count in your
~/.vimrc
:
let g:phpcs_max_output = 0 " Unlimited output.
" or
let g:phpcs_max_output = 2000 " Output limited to 2000 line
See the official documentation.
This doc and standard has mainly been taken from the Symfony2 coding standard