bugatino / phpcs-git-pre-commit
Setup PHPCS for checking PSR-2 standard using composer and git pre-commit hook.
Installs: 3 820
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 36
Language:Shell
Type:scripts
Requires (Dev)
This package is not auto-updated.
Last update: 2024-11-01 10:39:43 UTC
README
About
Auto installed git pre-commit hook for running PHP Code Sniffer code checking to PSR2 coding standard compliance. It checks only files that are to be committed.
Inspired by Enforce code standards with composer, git hooks, and phpcs
Installation
Install bugatino/phpcs-git-pre-commit
with composer require command:
composer require "bugatino/phpcs-git-pre-commit"
Or alternatively, include a dependency for bugatino/phpcs-git-pre-commit
in your composer.json file manually:
{
"require-dev": {
"bugatino/phpcs-git-pre-commit": "dev-master"
}
}
To enable code sniff, аdd to post-install-cmd
and post-update-cmd
in composer.json
installation script:
"scripts": {
"post-install-cmd": [
"sh ./vendor/bugatino/phpcs-git-pre-commit/src/setup.sh"
],
"post-update-cmd": [
"sh ./vendor/bugatino/phpcs-git-pre-commit/src/setup.sh"
]
}
Then run composer install
or composer update
using Git Bash
. pre-commit
hook will be installed or updated if it already exists.
Usage
Run git commit
and pre-commit hook will check your committed files like if you run
php phpcs.phar --standard=PSR2 --encoding=utf-8 -n -p /path/to/file.php