PHPackages                             jeleb-smile/php-git-hooks - 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. jeleb-smile/php-git-hooks

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

jeleb-smile/php-git-hooks
=========================

Git hooks for PHP projects.

v4.11.1(9y ago)01.0k1MITPHPPHP &gt;=5.6

Since Jan 3Pushed 8y agoCompare

[ Source](https://github.com/jeleb-smile/php-git-hooks)[ Packagist](https://packagist.org/packages/jeleb-smile/php-git-hooks)[ RSS](/packages/jeleb-smile-php-git-hooks/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (19)Versions (52)Used By (0)

php-git-hooks
=============

[](#php-git-hooks)

[![Build Status](https://camo.githubusercontent.com/6fe6c234939446215801f8061f80a19bbbc817c7a6fb1ef6fa3c6457e391c94e/68747470733a2f2f7472617669732d63692e6f72672f6272756c692f7068702d6769742d686f6f6b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bruli/php-git-hooks)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/540074d208437caa6d6e99302bc3feec3b80d7171847a01e2506652c0bf4f3ff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6272756c692f7068702d6769742d686f6f6b732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bruli/php-git-hooks/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/b1759cd59e981f251230d6f772090000f1f4d1cced0deaaca5f0f254ea855407/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6272756c692f7068702d6769742d686f6f6b732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bruli/php-git-hooks/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/e37a2b31b4fa450ad55763a34b8a0cb2fc750d6843df61afe0d0e3a510e585e8/68747470733a2f2f706f7365722e707567782e6f72672f6272756c692f7068702d6769742d686f6f6b732f762f737461626c652e737667)](https://packagist.org/packages/bruli/php-git-hooks) [![Total Downloads](https://camo.githubusercontent.com/ed203aa969019a518886fb1f0ecbe7d6a1480ac7d51f08fbdaa7171fde8a9308/68747470733a2f2f706f7365722e707567782e6f72672f6272756c692f7068702d6769742d686f6f6b732f646f776e6c6f616473)](https://packagist.org/packages/bruli/php-git-hooks) [![Latest Unstable Version](https://camo.githubusercontent.com/08224c6afbdadbc5e78a02077d22376218eb9570344258c3c6d938868ad02895/68747470733a2f2f706f7365722e707567782e6f72672f6272756c692f7068702d6769742d686f6f6b732f762f756e737461626c652e737667)](https://packagist.org/packages/bruli/php-git-hooks) [![License](https://camo.githubusercontent.com/1cf785b8988bc8ec9c3e06b9bab34f8352809ad071a8fa436e7889544fa93389/68747470733a2f2f706f7365722e707567782e6f72672f6272756c692f7068702d6769742d686f6f6b732f6c6963656e73652e737667)](https://packagist.org/packages/bruli/php-git-hooks)[![SensioLabsInsight](https://camo.githubusercontent.com/939ebae9656bd7c048252c9feb596310193ccaf47d34a1a981f4fcc347b10e35/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35383465623463652d376465322d346262302d393732382d3565386265386534636133662f6d696e692e706e67)](https://insight.sensiolabs.com/projects/584eb4ce-7de2-4bb0-9728-5e8be8e4ca3f)

Git hooks for PHP projects.

Library based in git hook scripts for PHP projects.

[Original scripts](http://carlosbuenosvinos.com/write-your-git-hooks-in-php-and-keep-them-under-git-control/)

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

[](#installation)

### Step 1: Composer

[](#step-1-composer)

You must add the following line to the `composer.json` file to use with Symfony 3.0:

```
{
    "require-dev": {
        "bruli/php-git-hooks": "~3.0"
    }
}
```

You can use "~2.0" for Symfony version 2.X.

Or you can write in your console:

```
$ composer require bruli/php-git-hooks --dev
```

If you don't have composer, you need download the binary file and run it:

```
wget http://getcomposer.org/composer.phar
# or
curl -O http://getcomposer.org/composer.phar

php composer.phar install
```

Step 2: Configuration
---------------------

[](#step-2-configuration)

### Composer configuration.

[](#composer-configuration)

After download all repositories, composer ask you about configuration.

[![](https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/composer-config.png)](https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/composer-config.png)

### Composer configuration in Symfony2 projects.

[](#composer-configuration-in-symfony2-projects)

In Symfony2 projects you need add this lines in your composer.json:

```
"scripts": {
    "post-install-cmd": [
      ...other lines...
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ],
    "post-update-cmd": [
      ...other lines...
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ]
```

**Important: To use 2.X version you need symfony 2.7 version.**

### Bin directory configuration.

[](#bin-directory-configuration)

If your project haven't a "bin" directory, you can add this in your compose.json file.

```
 "config": {
        "bin-dir": "bin"
    }
```

**Note: Not necessary for Symfony projects.**

### Manual config file for git hooks.

[](#manual-config-file-for-git-hooks)

You can configure php-git-hooks, creating a php-git-hooks.yml file with...

```
pre-commit:
  enabled: true
  execute:
    php-cs-fixer:
        enabled:  true
        levels:
            psr0:       true
            psr1:       true
            psr2:       true
            symfony:    true
    phpunit:
        enabled:     true
        random-mode: true
    phplint:         true
    phpcs:
        enabled:     true
        standard:    PSR2
    phpmd:           true
    composer:        true
commit-msg:
    enabled: true
    regular-expression: '#[0-9]{2,7}'
```

... or you can copy php-git-hooks.yml.sample from vendor/bruli/php-git-hooks.

### Update from v1.3.\*

[](#update-from-v13)

Php-cs-fixer configuration in php-git-hooks.yml file, is not compatible with 2.0 version. You should remove php-cs-fixer entry and execute "composer install".

Most easy way to update is delete php-git-hooks.yml and execute "composer install". You will see all the configuration questions again.

### Config file for phpunit.

[](#config-file-for-phpunit)

If you want use phpunit tool, you must create a phpunit.xml.dist in your project root directory. Alternatively you can copy from vendor/bruli/php-git-hooks/phpunit.xml.dist in your project root directory.

### Config file for phpmd.

[](#config-file-for-phpmd)

The same case that phpunit. You must create a PmdRules.xml in your project root directory or copy from php-git-hook directory.

Step 3: Enabling hooks.
-----------------------

[](#step-3-enabling-hooks)

The most easy way to enable hook is copy hook file into your .git/hooks directory.

\#For pre-commit hook:

You can enable this hooks with composer or manually executing

```
 $cp vendor/bruli/php-git-hooks/hooks/pre-commit .git/hooks
```

\#For commit-msg hook:

```
 $cp vendor/bruli/php-git-hooks/hooks/commit-msg .git/hooks
```

### execute.

[](#execute)

\####Valid pre-commit. [![](https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit.png)](https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit.png)\####Fail pre-commit. [![](https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit-failed.png)](https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit-failed.png)

Credits
-------

[](#credits)

- Pablo Braulio ([@brulics](https://twitter.com/brulics))
- [All contributors](https://github.com/bruli/php-git-hooks/graphs/contributors)

License
-------

[](#license)

php-git-hooks is released under the MIT License. See the bundled LICENSE file for details.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 92.5% 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 ~16 days

Recently: every ~6 days

Total

51

Last Release

3393d ago

Major Versions

v1.3.1 → v2.0.02015-09-01

v2.4.1 → v3.0.02015-12-08

v2.5.0 → v4.02016-02-27

PHP version history (4 changes)1.1-alphaPHP &gt;=5.3.3

v1.2.0PHP &gt;=5.4

v2.0.0PHP &gt;=5.5

v2.4.0PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25824424?v=4)[jeleb-smile](/maintainers/jeleb-smile)[@jeleb-smile](https://github.com/jeleb-smile)

---

Top Contributors

[![bruli](https://avatars.githubusercontent.com/u/760646?v=4)](https://github.com/bruli "bruli (369 commits)")[![patxi1980](https://avatars.githubusercontent.com/u/1370286?v=4)](https://github.com/patxi1980 "patxi1980 (13 commits)")[![tophsic](https://avatars.githubusercontent.com/u/930980?v=4)](https://github.com/tophsic "tophsic (3 commits)")[![abacaphiliac](https://avatars.githubusercontent.com/u/1656273?v=4)](https://github.com/abacaphiliac "abacaphiliac (2 commits)")[![neoshadybeat](https://avatars.githubusercontent.com/u/350521?v=4)](https://github.com/neoshadybeat "neoshadybeat (2 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![jeleb-smile](https://avatars.githubusercontent.com/u/25824424?v=4)](https://github.com/jeleb-smile "jeleb-smile (1 commits)")[![lgarciaes](https://avatars.githubusercontent.com/u/6773433?v=4)](https://github.com/lgarciaes "lgarciaes (1 commits)")[![stmswitcher](https://avatars.githubusercontent.com/u/10289021?v=4)](https://github.com/stmswitcher "stmswitcher (1 commits)")[![Faryshta](https://avatars.githubusercontent.com/u/2029247?v=4)](https://github.com/Faryshta "Faryshta (1 commits)")[![ruudy-es](https://avatars.githubusercontent.com/u/6099611?v=4)](https://github.com/ruudy-es "ruudy-es (1 commits)")[![emmetog](https://avatars.githubusercontent.com/u/1182891?v=4)](https://github.com/emmetog "emmetog (1 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (1 commits)")[![jaceju](https://avatars.githubusercontent.com/u/310474?v=4)](https://github.com/jaceju "jaceju (1 commits)")

---

Tags

qualitygitHOOK

### Embed Badge

![Health badge](/badges/jeleb-smile-php-git-hooks/health.svg)

```
[![Health](https://phpackages.com/badges/jeleb-smile-php-git-hooks/health.svg)](https://phpackages.com/packages/jeleb-smile-php-git-hooks)
```

###  Alternatives

[bruli/php-git-hooks

Git hooks for PHP projects.

669371.6k5](/packages/bruli-php-git-hooks)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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