Tom Schuermans


Composer - Enforcing GIT hooks

Composer allows you to use custom plugins to add extra behaviour to install, update, uninstall, ... events. The first time I "discovered" this extra functionality was during a talk by Toon Verwerft (@toonverwerft) about GrumPHP, a PHP QA tool.

GrumPHP

GrumPHP is a Composer plugin which installs a couple of GIT hooks in your repository, which perform QA checking on your project.

The copying of the GIT hooks is actually pretty easy using a plugin, you just attach event handlers to certain Composer package/script events such as install, update and uninstall.

Implementation example

I made two repositories which display how easily you can enforce git hooks for all your projects by requiring 1 extra package.

Check TSchuermans/enforce-hooks for the source code of the plugin (very basic stuff) and TSchuermans/enforce-hooks-implementation for an implementation example of said plugin.

Creating your own implementation

You can easily customise which GIT hooks should be enforced by forking my repository and placing your own GIT hooks in the hooks directory.

Note: If you want, you can still bypass commit checking by adding the –no-verify option to your commit command.

tschuermans.be