Skip to content

A basic pre-commit hook for Git running PHP_CodeSniffer

License

Notifications You must be signed in to change notification settings

osteel/git-pre-commit-phpcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Pre-commit hook for Git running PHP_CodeSniffer

This a basic pre-commit hook for Git running PHP_CodeSniffer on newly committed changes and offering to fix violations automatically when possible.

Installation

Download the pre-commit file and put it under .git/hooks at the root of your project.

Make sure it is executable:

$ chmod +x pre-commit

Install PHP_CodeSniffer following one of the suggested methods.

I personally like to install it for the projects that need it only, as a Composer dependency:

$ composer require --dev squizlabs/php_codesniffer

Configuration

The default standard is PSR-12, but you can change it by updating the STANDARD variable at the top of the file.

Likewise, the script assumes that PHP_CodeSniffer's bin folder is at the same level as the .git folder by default, but you can set a different location by updating the BIN variable.

For other standards and options, please visit the usage page.

Contribute

While this repository is not intended to grow, PRs are welcome, especially since my Bash-fu isn't very strong.

About

A basic pre-commit hook for Git running PHP_CodeSniffer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages