Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smgladkovskiy/phpcs-git-pre-commit
Code sniffer git pre-commit hook. Composer installation.
https://github.com/smgladkovskiy/phpcs-git-pre-commit
Last synced: about 2 months ago
JSON representation
Code sniffer git pre-commit hook. Composer installation.
- Host: GitHub
- URL: https://github.com/smgladkovskiy/phpcs-git-pre-commit
- Owner: smgladkovskiy
- License: mit
- Created: 2017-01-14T09:25:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-04T19:55:16.000Z (over 1 year ago)
- Last Synced: 2024-09-20T05:41:57.502Z (3 months ago)
- Language: Shell
- Size: 14.6 KB
- Stars: 38
- Watchers: 3
- Forks: 36
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHPCS git pre-commit hook
## About
Auto installed git pre-commit hook for running [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer)
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](http://tech.zumba.com/2014/04/14/control-code-quality/)
## Installation
Install `smgladkovskiy/phpcs-git-pre-commit` with composer require command:
composer require --dev "smgladkovskiy/phpcs-git-pre-commit"
Or alternatively, include a dependency for `smgladkovskiy/phpcs-git-pre-commit` in your composer.json file manually:
{
"require-dev": {
"smgladkovskiy/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": {
"install-hooks": ["sh ./vendor/smgladkovskiy/phpcs-git-pre-commit/src/setup.sh"],
"post-install-cmd": ["@install-hooks"],
"post-update-cmd": ["@install-hooks"]
}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=PSR2 --encoding=utf-8 -n -p /path/to/file.php
## Contributing
Feel free to make pull requests!