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

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

wcm/git-php-hooks
=================

Write git hooks with PHP, organize them on a per-project base and automatically add them

v1.0.0(11y ago)6441.1k↑40.9%6[1 issues](https://github.com/wecodemore/GitPHPHooks/issues)3MITPHPPHP &gt;=5.3

Since Jul 31Pushed 10y ago5 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (3)

[![Latest Stable Version](https://camo.githubusercontent.com/6e2115e2154616d957a0ca608c1bbdb7b61acfa7890535fb796390c0cd747dc2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77636d2f6769742d7068702d686f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wcm/git-php-hooks)[![Latest Git Release](https://camo.githubusercontent.com/6819c05c767ca35d6deeabb7585f7eb46a290bc9cc08dae2026f9e47cb0fafb5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f7765636f64656d6f72652f476974504850486f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://github.com/wecodemore/GitPHPHooks/releases)[![Total Downloads](https://camo.githubusercontent.com/6eb392337467f785f3748b14579ad9d554e2adc892abe2d74c841dbc999cccea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77636d2f6769742d7068702d686f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wcm/git-php-hooks)[![License](https://camo.githubusercontent.com/a046900080751bf64db09ed2e8bb0f62977b47669059c9ac8803dd2e0809ccba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77636d2f6769742d7068702d686f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wcm/git-php-hooks)[![GitHub Stars](https://camo.githubusercontent.com/67641daef41750ea01d373e4067b48937713a26e51c65432fa69c2709177297a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f7765636f64656d6f72652f476974504850486f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://github.com/wecodemore/GitPHPHooks/stargazers)

[![Git Logo](https://camo.githubusercontent.com/10fac1465a49ffcef13e7292d29e34a71a6387ab49db7993fbd70d15a03adf83/687474703a2f2f692e696d6775722e636f6d2f717a76775434432e706e67)](https://camo.githubusercontent.com/10fac1465a49ffcef13e7292d29e34a71a6387ab49db7993fbd70d15a03adf83/687474703a2f2f692e696d6775722e636f6d2f717a76775434432e706e67)

Git PHP Hooks
=============

[](#git-php-hooks)

Write your git hooks in PHP, organize them on a per project base and attach them automatically.

Git Hooks
---------

[](#git-hooks)

> Hooks are little scripts you can place in `$GIT_DIR/hooks` directory to trigger action at certain points.

There're two types of git hooks:

1. pre-push (runs client side)
2. post-push (runs server side)

For more info on Git Hooks, please [take a look at the official docs](http://git-scm.com/docs/githooks) - they are quite good.

How to
------

[](#how-to)

It's really easy:

1. Add a folder to your project/repository. The name doesn't matter, as you have to specify it when triggering `GitPHPHooks`. The name in the following example is `'project-hooks'`. (Hint: Not having a name allows you to customize and organize it as you like. It also allows `git clone`ing into a project specific directory.)
2. Open your `.git/hooks` directory and add a new Git hook file. For example: `pre-commit`(without file extension).
3. Add a new PHP file to the newly created custom Git hooks folder (again, `'project-hooks'` in the example) that performs the task you want.

That's it.

All your Git hooks (inside `.git/hooks`) will have the same contents - only the target folder (`'project-hooks'`) name will (maybe) differ.

```
#!/usr/bin/env php
