Download the PHP package wcm/git-php-hooks without Composer

On this page you can find all versions of the php package wcm/git-php-hooks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package git-php-hooks

Latest Stable Version Latest Git Release Total Downloads License GitHub Stars

Git Logo

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)
  2. post-push (runs server side)

For more info on Git Hooks, please take a look at the official docs - 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 cloneing 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.

Explanation:

Naming convention

There's a naming convention that you must follow to properly attach PHP files to Git hooks. Sorting files is also done by file name.

  1. If a Git hook name is found in the file name, it will get attached to this specific hook and executed automatically. Example: pre-commit_
  2. If one of your hooking PHP files has a number attached, it will get added with this priority. Example: _10 If it ain't got any int in the file name, it will get skipped. This is useful to temporarily disable files if you are testing the order or a new hook.
  3. The name in between the Git hook name and the priority is just an identifiyer for yourself. Example: PHPUnit

Examples (and ready-to-use tasks)

Before jumping on examples, I suggest that you simply take a look at the GitPHPHooks Library repo. You will find a PHPLint and a PHP Mess Detector task and some others (hint: I happily accept pull requests!).

A real world scenario (simplified version of the task that is available in the linked library)

We want to run PHPLint before we commit

Add 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:

Of course, above code is a very poor example. For a more detailed one, please refer to the library linked above. The GitPHPHooks Library runs two real world examples. To use PHP Mess Detector and PHPLint, I can just suggest using the library as those are currently built in. Again: If you have a custom one and want to share, just send a Pull Request.

Grunt integration

It can easily be integrated with grunt via grunt-githooks, originally written by @rhumaric.

Setup your grunt-githooks task like this:

Then just add your hooked tasks to your project and use the following template:

This example is assuming that you are using the GitPHPHooksLibrary. The template in this case would be located inside a templates directory in the root folder of your project and be named git-php-hooks.tmpl.hb. It's important to set the hooks names value to none as GitPHPHooks doesn't need a task name as it identifies tasks by the filename by itself.

Install

Add the repo to your stack. You can use Composer (w/o Satis as it's added to Packagist). Simply add

to your composer.json file. GitHub has a service hook added to this repo to auto-update whenever this repo is updated. The ^1.0 version number will bring you all patches without breaking anything.

To add the repository to the dev-part of the stack in composer.json, the following command can be typed in the prompt (assuming composer is in your PATH or aliased ).

composer require --dev --prefer-dist -- wcm/git-php-hooks

wcm/git-php-hooks suggests installing a library of pre made hooks and tasks, wcm/git-php-hooks-library . To add this with composer the following can be used:

composer require --dev --prefer-dist -- wcm/git-php-hooks-library

All versions of git-php-hooks with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wcm/git-php-hooks contains the following files

Loading the files please wait ....