smgladkovskiy/phpcs-git-pre-commit

PHPCS check before commit

Maintainers

👁 smgladkovskiy

Package info

github.com/smgladkovskiy/phpcs-git-pre-commit

Language:Shell

Type:scripts

pkg:composer/smgladkovskiy/phpcs-git-pre-commit

Statistics

Installs: 32 884

Dependents: 3

Suggesters: 0

Stars: 39

Open Issues: 1

dev-master 2022-04-12 06:32 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 5b8e5d64f75d1d290cc41d8dde80cde3f84a9a6a

  • Sergey Gladkovskiy <smgladkovskiy.woop@gmail.com>

This package is not auto-updated.

Last update: 2026-06-07 06:15: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

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!