PHPackages                             sdieunidou/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. [Testing &amp; Quality](/categories/testing)
4. /
5. sdieunidou/php-git-hooks

AbandonedLibrary[Testing &amp; Quality](/categories/testing)

sdieunidou/php-git-hooks
========================

Git hooks for PHP projects.

v2.0.1(10y ago)0331MITPHPPHP &gt;=5.5

Since Jan 3Pushed 10y ago1 watchersCompare

[ Source](https://github.com/sdieunidou/php-git-hooks)[ Packagist](https://packagist.org/packages/sdieunidou/php-git-hooks)[ RSS](/packages/sdieunidou-php-git-hooks/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (13)Versions (10)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:

```
{
    "require-dev": {
        "bruli/php-git-hooks": "2.*@dev"
    }
}
```

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
        level:    psr0
    phpunit:       true
    phplint:       true
    phpcs:         true
    phpmd:         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

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 90.6% 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 ~30 days

Recently: every ~52 days

Total

9

Last Release

3912d ago

Major Versions

v1.3.1 → v2.0.02015-09-01

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

v1.2.0PHP &gt;=5.4

v2.0.0PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/077eba6702dc23a795ee2262dff92505e3c8ead08f7cb205be80d8aae0a6b8e5?d=identicon)[sdieunidou](/maintainers/sdieunidou)

---

Top Contributors

[![bruli](https://avatars.githubusercontent.com/u/760646?v=4)](https://github.com/bruli "bruli (126 commits)")[![sdieunidou](https://avatars.githubusercontent.com/u/570763?v=4)](https://github.com/sdieunidou "sdieunidou (5 commits)")[![patxi1980](https://avatars.githubusercontent.com/u/1370286?v=4)](https://github.com/patxi1980 "patxi1980 (4 commits)")[![neoshadybeat](https://avatars.githubusercontent.com/u/350521?v=4)](https://github.com/neoshadybeat "neoshadybeat (2 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (1 commits)")[![lgarciaes](https://avatars.githubusercontent.com/u/6773433?v=4)](https://github.com/lgarciaes "lgarciaes (1 commits)")

---

Tags

qualitygitHOOK

### Embed Badge

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

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

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[bruli/php-git-hooks

Git hooks for PHP projects.

675370.8k5](/packages/bruli-php-git-hooks)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)[lastzero/test-tools

Increases testing productivity by adding a service container and self-initializing fakes to PHPUnit

2244.3k13](/packages/lastzero-test-tools)

PHPackages © 2026

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