Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wecodemore/GitPHPHooks
Write your Git Hooks in PHP, organize them on a per-project base and automatically add them.
https://github.com/wecodemore/GitPHPHooks
Last synced: about 2 months ago
JSON representation
Write your Git Hooks in PHP, organize them on a per-project base and automatically add them.
- Host: GitHub
- URL: https://github.com/wecodemore/GitPHPHooks
- Owner: wecodemore
- Created: 2014-07-18T16:18:20.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-05T00:43:01.000Z (over 8 years ago)
- Last Synced: 2024-09-25T07:21:04.226Z (3 months ago)
- Language: PHP
- Size: 19.5 KB
- Stars: 64
- Watchers: 8
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-git-hooks - GitPHPHooks - Write your hooks in PHP, manage and organize them on a task and project level. Has an additional Hooks library on GitHub. (Projects)
README
[![Latest Stable Version](https://img.shields.io/packagist/v/wcm/git-php-hooks.svg?style=flat-square)](https://packagist.org/packages/wcm/git-php-hooks)
[![Latest Git Release](https://img.shields.io/github/tag/wecodemore/GitPHPHooks.svg?style=flat-square)](https://github.com/wecodemore/GitPHPHooks/releases)
[![Total Downloads](https://img.shields.io/packagist/dt/wcm/git-php-hooks.svg?style=flat-square)](https://packagist.org/packages/wcm/git-php-hooks)
[![License](https://img.shields.io/packagist/l/wcm/git-php-hooks.svg?style=flat-square)](https://packagist.org/packages/wcm/git-php-hooks)
[![GitHub Stars](https://img.shields.io/github/stars/wecodemore/GitPHPHooks.svg?style=flat-square)](https://github.com/wecodemore/GitPHPHooks/stargazers)![Git Logo](http://i.imgur.com/qzvwT4C.png)
# Git PHP Hooks
Write your git hooks in PHP, organize them on a per project base and attach them automatically.
## 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)
1. 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
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.)
1. Open your `.git/hooks` directory and add a new Git hook file. For example: `pre-commit`
(without file extension).
1. 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.
```php
#!/usr/bin/env php
We want to run PHPLint before we commitAdd a new file named `pre-commit` in your `.git/hooks` directory. Then add a new directory in the
root folder of your project/repository, named i.e. `project-hooks`. In there, add a new PHP file
named `pre-commit_lint_10.php`. This file will automatically get added to your `pre-commit` hook
where you called the `\GitHooksLoader()` like shown above. It will get added with a priority
of 10. Then just put the following contents in your new file:```php
#!/usr/bin/env php