This script runs PHP-CS-Fixer before committing code.
The fixer is run quietly to avoid any output. If there are violations, it is run again in verbose mode to provide information about the violations.
Only changed files since the last commit are checked, unless configuration files that might impact all files are changed, in which case a full check is done.
This hook is invoked by git commit
, and can be bypassed using the --no-verify
option.
git commit --no-verify
Environment variables
PHP_CS_FIXER_IGNORE_ENV=1
XDEBUG_MODE=off
Create the hooks directory:
mkdir ~/.githooks
Download or copy the pre-commit
script to:
~/.githooks/pre-commit
Ensure the file is executable:
chmod 744 ~/.githooks/pre-commit
Configure the Git hooks path:
git config --global core.hooksPath ~/.githooks
Released under the GPL-3.0-or-later License.