Skip to content

Latest commit

 

History

History
48 lines (30 loc) · 1.15 KB

File metadata and controls

48 lines (30 loc) · 1.15 KB

PHP-CS-Fixer Pre-Commit Hook

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

Installation

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

License

Released under the GPL-3.0-or-later License.