Last Updated: September 09, 2019
·
7.666K
· dmtrs

5 commands to be a better PHP developer

Following commands will add you the CodeSniffer pear package and set it to check for the PSR standards before committing anything to your git repository. No need to what the previous acronyms are about (expect pear and git :) ).
Just do the following:

# pear install PHP_CodeSniffer
# cd /usr/share/pear/PHP/CodeSniffer/Standards/
# git clone http://github.com/klaussilveira/phpcs-psr PSR

Note: The CodeSniffer directory may vary for your system.

$ cd /path/to/your/project/.git/hooks/
$ wget http://raw.github.com/dmtrs/git-hooks/master/phpcs-pre-commit/pre-commit

3 Responses
Add your response

optimum

over 1 year ago ·

You need to mark the pre-commit hook as executable if you want git to invoke it.

chmod +x pre-commit

over 1 year ago ·

Since of PHP_CodeSniffer 1.4.x PSR is distributed with phpcs - so no need for an extra download.

over 1 year ago ·