richweber / yii2-code-sniffer-git-hook
Code Sniffer Git Hook
Installs: 21 940
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: >=2.0.8
- yiisoft/yii2-coding-standards: >=2.0.1
This package is auto-updated.
Last update: 2024-12-21 20:52:18 UTC
README
You can read about Yii2 standard here: https://github.com/yiisoft/yii2/blob/master/docs/internals/core-code-style.md
How to install
Getting Yii2 code standard
$ git clone git://github.com/yiisoft/yii2-coding-standards.git
Install composer
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
Install Code Sniffer
$ composer global require "squizlabs/php_codesniffer=*"
Install Yii2 code standard
$ cd yii2-coding-standards
$ cp -r Yii2 ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Yii2
Check Yii2 standard
$ phpcs -i
Set Yii2 as coding standard by default:
$ phpcs --config-set default_standard Yii2
Install Git hooks
$ git clone git@github.com:RichWeber/yii2-code-sniffer-git-hook.git
$ cp yii2-code-sniffer-git-hook/pre-commit /YOUR_PROJECT/.git/hooks/pre-commit
$ cp yii2-code-sniffer-git-hook/pre-commit_yii2cs /YOUR_PROJECT/.git/hooks/pre-commit_yii2cs
$ cp yii2-code-sniffer-git-hook/.hooks_ignore /YOUR_PROJECT/.hooks_ignore
Check Git hooks
$ cd /YOUR_PROJECT
$ git commit