Composer CodeSniffer Git Hooks
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
LICENSE.md
README.md
composer.json
phpunit.xml.dist

README.md

Composer CodeSniffer Hooks

Build Status Downloads this Month Latest stable

Hooks to enable PHP CodeSniffer with the Coding Standard configurable after running composer install or composer update.

Install

Install dependency via composer:

$ composer require --dev metasyntactical/composer-codesniffer-hooks

Add scripts to composer post hooks:

"scripts": {
    "post-install-cmd": [
        "MetaSyntactical\\CodeSniffer\\Composer\\ScriptHandler::addPhpCsToPreCommitHook"
    ],
    "post-update-cmd": [
        "MetaSyntactical\\CodeSniffer\\Composer\\ScriptHandler::addPhpCsToPreCommitHook"
    ]
}

Add the codesniffer standard which has been installed as dependency (e.g. "metasyntactical/symfony-coding-standard") to the extra field in composer.json:

"extras": {
    "codesniffer": {
        "standard": {
            "dependency": "metasyntactical/symfony-coding-standard"
        }
    }
}

On each composer install or composer update the hook will be deployed to the local git repository.

Usage

Every time you try to commit, PHP_CodeSniffer will run on changed .php files only. There is nothing to do manually.