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-verifyEnvironment variables
PHP_CS_FIXER_IGNORE_ENV=1XDEBUG_MODE=off
Create the hooks directory:
mkdir ~/.githooksDownload or copy the pre-commit script to:
~/.githooks/pre-commitEnsure the file is executable:
chmod 744 ~/.githooks/pre-commitConfigure the Git hooks path:
git config --global core.hooksPath ~/.githooksReleased under the GPL-3.0-or-later License.