PhpGitHooks
, (*1)
This project contains some simple scripts to run Unit tests and static analysis tools before allowing a commit., (*2)
Currently the tool will run:, (*3)
- PHPUnit
- PHP Copy Paste Detector
- PHP Code Sniffer
The tool will only run phpcs on modified files where phpcpd will be run against all files. PHPUnit will be run if there if a phpunit.xml or phpunit.xml.dist file in the root of the project., (*4)
PHP Code Sniffer will be run with ps2 coding standard and warning will be ingored (eg line limits), (*5)
This script will look for binaries in either the project's vendor/bin
directory first and will fall back to ~/.composer/vendor/bin
so make sure the tools are installed with composer., (*6)
See PHP-FIG for the coding standards., (*7)
composer global require 'phpunit/phpunit:3.7.*'
composer global require 'squizlabs/php_codesniffer:1.5.1'
composer global require 'sebastian/phpcpd=2.0.0'
Install hooks
composer global require 'aydin-hassan/php-git-hooks:0.1.0-beta3'
cd ~/.composer/vendor/aydin-hassan/php-git-hooks
./install.sh
If you have any existing repositories you should run git init
in the root of the repo to enable the hooks in them. All new repos will inherit the hooks., (*8)
Done
Everytime you commit something from any newly cloned/ created repository these checks will be executed!, (*9)
Todo
- [ ] Figure out how to execute global hooks if local repo hooks are defined