si6 / pre-commit-hook
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Installs: 6 096
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 2
Open Issues: 0
Language:PowerShell
pkg:composer/si6/pre-commit-hook
Requires
- phpunit/phpunit: ^8.3
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2021-09-06 19:50:40 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 and https://github.com/smgladkovskiy/phpcs-git-pre-commit and https://gist.github.com/BrizzleRocker/62ed61b37acf05344d4bce894e719251 . Installer checks OS on hosting machine and installs needed hooks for platform.
Installation
Install si6/pre-commit-hook with composer require command:
composer require "si6/pre-commit-hook"
Or alternatively, include a dependency for si6/pre-commit-hook in your composer.json file manually:
{
"require-dev": {
"si6/pre-commit-hook": "*"
}
}
To enable code sniff, аdd to post-install-cmd and post-update-cmd in composer.json installation script:
"scripts": {
"post-install-cmd": [
"Si6\\PreCommitHook\\Installer::postInstall"
],
"post-update-cmd": [
"Si6\\PreCommitHook\\Installer::postInstall"
]
}
Then run composer install or composer update. 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=rule.xml --colors --encoding=utf-8 -n -p /path/to/file.php