PHPackages                             andkirby/commithook - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. andkirby/commithook

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

andkirby/commithook
===================

PHP Commit Hooks

v1.8.0-p3(11y ago)7154proprietaryPHP &gt;=5.3.2

Since Jan 5Compare

[ Source](https://github.com/andkirby/commithook)[ Packagist](https://packagist.org/packages/andkirby/commithook)[ RSS](/packages/andkirby-commithook/feed)WikiDiscussions Synced today

READMEChangelog (10)Dependencies (3)Versions (73)Used By (0)

CmHook
======

[](#cmhook)

CmHook is GIT commit hook the code validator for PHP (Code Sniffer), CSS (base only), JS (JsHint) code and commit message formatter/filler with the issue tracker integration (JIRA, GitHub).

[![Gitter](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/andkirby/commithook?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

The main purpose of this project is

- checking coding standards before commit (by using PHP CodeSniffer, JSHint, RuboCop, or any lint tool)
- filling up commit messages automatically to proper format ([details](docs/commit-msg.md))

Supported file types: php, phtml, js, coffee, css, scss, xml, sh, scss, css, json, less, html, htm.

The simplest commit message you could ever make
-----------------------------------------------

[](#the-simplest-commit-message-you-could-ever-make)

Target commit message:

```
Implemented #33: Make smth good now
 - Added my file.

```

This commit message will be generated automatically, we need to type only commit description:

```
$ git add myfile.php
$ git commit -m 'Added my file.'

```

See more details about [short commit messages](docs/commit-msg.md).

Installation
------------

[](#installation)

### Latest release is `v2.0.0-beta.47`

[](#latest-release-is-v200-beta47)

### Install globally

[](#install-globally)

To get last beta version please define your `minimum-stability`.

```
{
  "minimum-stability": "beta",
  "prefer-stable": true
}

```

Due to reason the package requires one package which still in "dev", please fetch it first:

```
$ composer global require chobie/jira-api-restclient ^2.0@dev
```

Now fetch the package:

```
$ composer global require andkirby/commithook ~2.0@beta
```

### Enable hooks in a project (with predefined configuration)

[](#enable-hooks-in-a-project-with-predefined-configuration)

If a project already have base configuration files all what you need to:

- define interpreters (PHP for PHPCS, Ruby for Rubocop, NodeJs for JSHint)
    - PHP example: ```
        $ commithook config --xpath code/interpreter/php d:/s/php-7.0.14/php.exe --project-self
        ```

        (You may try to use [PHP Windows Binaries Downloader (gist)](https://gist.github.com/andkirby/67e87e319c376b8676d559edb759e3fe))
- Install extra code validators:
    - PHPCS ```
        $ composer global require squizlabs/php_codesniffer:~2.0@stable
        ```
    - [JSHint](docs/jshint-setup.md) ([original](http://jshint.com/install/)).
    - [Rubocop installation](https://github.com/bbatsov/rubocop/blob/master/manual/installation.md).
- (optional) Perhaps, you have to define binaries for extra code validators in case they are not allow to use globally. (e.g. [JSHint](docs/jshint-setup.md), any see how to install any "linter" in [this example](src/config/examples/pre-commit/Linter-SimplyLint.xml).)
- Install GIT hook files ```
    $ commithook install

    ```
- Enable your tracker integration: ```
    $ commithook tracker:wizard

    ```

#### Sample `.bashrc`

[](#sample-bashrc)

Here is [an example of `.bashrc` file](docs/example-bashrc.md) for global using.

### Separate installation

[](#separate-installation)

If global way doesn't work you may use [installation via `create-project`](docs/install-create-project.md).

Documentation references
------------------------

[](#documentation-references)

### Installation

[](#installation-1)

[Initialize configuration wizard](docs/example-quick-wizard.md)
[GIT integration: hook files installation](docs/hooks-installation.md)

### Password tracker update

[](#password-tracker-update)

[Password update](docs/example-wizard.md#password-reset)

### Code validation

[](#code-validation)

[Ignore validation](docs/exclude-code-validation.md)
[Protect code](docs/protect-code.md)
[Enable JsHint validation (Javascript)](docs/jshint-setup.md)

### Commit message

[](#commit-message)

[Commit message format](docs/commit-msg.md)
[Ignore commit message validation](docs/commit-msg-ignore.md)
[Active task in commit message](docs/active-task.md)
[Auto-explode commit message into the list](docs/config-message.md)

Problems
--------

[](#problems)

### Bugs

[](#bugs)

[Issue bugs list](../../labels/bug).

#### Code validators doesn't work with GIT cache

[](#code-validators-doesnt-work-with-git-cache)

The code validation works with GIT but it doesn't support git cache. It means if you added a file (`git add file.php`), changed it, and trying to commit (without adding it into GIT cache). In commit, of course, you will get code from cache but validators will validate your real file. ([\#113](../../issues/113))

#### Minor bugs in short commit message

[](#minor-bugs-in-short-commit-message)

[\#92](../../issues/92), [\#91](../../issues/91), [\#32](../../issues/32)

Tips &amp; tricks
-----------------

[](#tips--tricks)

### Redundant gaps in code

[](#redundant-gaps-in-code)

You may quickly find gaps/trailing spaces in your code by the regular expression:

```
(\n\s*\n\s*\})|(\n\s*\n\s*\n)|(\{\n\s*\n)| +\n

```

Just use it in your IDE.

OS environment
--------------

[](#os-environment)

Tested on Windows in GIT Bash v2.9.

Feel free [to create](../../issues/new "Add a new issue") your faced issue.

[Release notes](docs/release-notes.md)
--------------------------------------

[](#release-notes)

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 99.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

69

Last Release

3224d ago

Major Versions

v1.8.0-p3 → v2.0.0-beta.02015-10-12

PHP version history (3 changes)v1.6.5PHP &gt;=5.3.2

v2.0.0-beta.12PHP &gt;=5.6.2

v2.0.0-beta.18PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/79af1435892dd9111c06a5e386fd69b577a71f3fbcc3f20aab50db8e5abc8ce2?d=identicon)[andkirby](/maintainers/andkirby)

---

Top Contributors

[![andkirby](https://avatars.githubusercontent.com/u/1828532?v=4)](https://github.com/andkirby "andkirby (1214 commits)")[![igor518](https://avatars.githubusercontent.com/u/4254339?v=4)](https://github.com/igor518 "igor518 (3 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/andkirby-commithook/health.svg)

```
[![Health](https://phpackages.com/badges/andkirby-commithook/health.svg)](https://phpackages.com/packages/andkirby-commithook)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[phel-lang/phel-lang

Phel is a functional programming language that compiles to PHP

5186.0k18](/packages/phel-lang-phel-lang)[dagger/dagger

Dagger PHP SDK

261.1k](/packages/dagger-dagger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
