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

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

andriipidhainyi/php-git-hooks
=============================

Git hooks for PHP projects.

00PHP

Since Jul 3Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (1)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)[![Donate button](https://camo.githubusercontent.com/7b6de155df30b37b25eb5fec52f9213680c3dbf067dfb7d7e2850ac4096c7d05/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e6174655f534d2e676966)](https://www.paypal.me/brulics)

Git hooks for PHP projects.

Library based in git hook scripts for PHP projects.

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": "~4.1"
    }
}
```

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)

### Using Composer

[](#using-composer)

First, you will need to add the following lines to your `composer.json`

```
"scripts": {
    "post-install-cmd": [
      "PhpGitHooks\\Infrastructure\\Composer\\ConfiguratorScript::buildConfig"
    ],
    "post-update-cmd": [
      "PhpGitHooks\\Infrastructure\\Composer\\ConfiguratorScript::buildConfig"
    ]
}
```

**WARNING:** "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig" is deprecated. You need change by current entry.

Then, launch `$ composer install` and composer should 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)

### Bin directory configuration.

[](#bin-directory-configuration)

If your project doesn't have a "bin/" directory, you can add this in your `composer.json` file.

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

**Note:** This is 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
        options: "--fixers=short_array_syntax --diff"
    phpunit:
        enabled:     true
        random-mode: true
        options:     ''
        strict-coverage:
             enabled:       true
             minimum:       90
        guard-coverage:
             enabled: true
             message: 'WARNING!!, your code coverage is lower.'
    phplint:         true
    phpcs:
        enabled:     true
        standard:    PSR2
    phpmd:
        enabled:     true
        options:     ''
    composer:        true
  message:
    right-message: 'HEY, GOOD JOB!!'
    error-message: 'FIX YOUR CODE!!'
commit-msg:
    enabled: true
    regular-expression: '#[0-9]{2,7}'
pre-push:
    enabled: true
    execute:
      phpunit:
        enabled:     true
        random-mode: true
        options:     ''
    strict-coverage:
        enabled:       true
        minimum:       90
    guard-coverage:
        enabled: true
        message: 'WARNING!!, your code coverage is lower.'
    message:
      right-message: 'PUSH IT!!'
      error-message: 'YOU CAN NOT PUSH CODE!!'
```

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

### 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:
====================

[](#for-pre-commit-hook)

You can enable this hooks with composer or manually executing

```
$ cp vendor/bruli/php-git-hooks/src/PhpGitHooks/Infrastructure/Hook/pre-commit .git/hooks
```

For commit-msg hook:
====================

[](#for-commit-msg-hook)

```
$ cp vendor/bruli/php-git-hooks/src/PhpGitHooks/Infrastructure/Hook/commit-msg .git/hooks
```

For pre-push hook:
==================

[](#for-pre-push-hook)

```
$ cp vendor/bruli/php-git-hooks/src/PhpGitHooks/Infrastructure/Hook/pre-push .git/hooks
```

### execute.

[](#execute)

#### Valid pre-commit.

[](#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.

[](#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](https://opensource.org/licenses/MIT). See the bundled LICENSE file for details.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/28a94488298c4f2da661b7b0c0aaf7da449d9b369c49d27cd9d95291d347b9dc?d=identicon)[andriipidhainyi](/maintainers/andriipidhainyi)

---

Top Contributors

[![bruli](https://avatars.githubusercontent.com/u/760646?v=4)](https://github.com/bruli "bruli (423 commits)")[![mmarynich](https://avatars.githubusercontent.com/u/11662487?v=4)](https://github.com/mmarynich "mmarynich (16 commits)")[![patxi1980](https://avatars.githubusercontent.com/u/1370286?v=4)](https://github.com/patxi1980 "patxi1980 (14 commits)")[![minterior](https://avatars.githubusercontent.com/u/2928014?v=4)](https://github.com/minterior "minterior (6 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)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (1 commits)")[![infinitisno](https://avatars.githubusercontent.com/u/9398439?v=4)](https://github.com/infinitisno "infinitisno (1 commits)")[![jaceju](https://avatars.githubusercontent.com/u/310474?v=4)](https://github.com/jaceju "jaceju (1 commits)")[![JLepeltier](https://avatars.githubusercontent.com/u/1286287?v=4)](https://github.com/JLepeltier "JLepeltier (1 commits)")[![lgarciaes](https://avatars.githubusercontent.com/u/6773433?v=4)](https://github.com/lgarciaes "lgarciaes (1 commits)")[![danitome24](https://avatars.githubusercontent.com/u/7501990?v=4)](https://github.com/danitome24 "danitome24 (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")[![stmswitcher](https://avatars.githubusercontent.com/u/10289021?v=4)](https://github.com/stmswitcher "stmswitcher (1 commits)")[![bestony](https://avatars.githubusercontent.com/u/13283837?v=4)](https://github.com/bestony "bestony (1 commits)")[![rbrigot](https://avatars.githubusercontent.com/u/16192061?v=4)](https://github.com/rbrigot "rbrigot (1 commits)")[![ruudy-es](https://avatars.githubusercontent.com/u/6099611?v=4)](https://github.com/ruudy-es "ruudy-es (1 commits)")[![aftabnaveed](https://avatars.githubusercontent.com/u/58515?v=4)](https://github.com/aftabnaveed "aftabnaveed (1 commits)")

### Embed Badge

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

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

###  Alternatives

[components/jqueryui

jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.

1795.8M57](/packages/components-jqueryui)

PHPackages © 2026

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