PHPackages                             thecodingmachine/gitlab-hook-middleware - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. thecodingmachine/gitlab-hook-middleware

ActiveLibrary[HTTP &amp; Networking](/categories/http)

thecodingmachine/gitlab-hook-middleware
=======================================

A PSR-15 middleware to manage Gitlab hooks.

v1.0.1(6y ago)3712MITPHPPHP &gt;=7.1

Since Sep 10Pushed 6y ago6 watchersCompare

[ Source](https://github.com/thecodingmachine/gitlab-hook-middleware)[ Packagist](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)[ Docs](https://github.com/thecodingmachine/gitlab-hook-middleware)[ RSS](/packages/thecodingmachine-gitlab-hook-middleware/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (15)Versions (3)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/36929f72bcc7da782a2172ed8fcf9ceb993b4835ae25439a4ac240160a4b3a2b/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f6769746c61622d686f6f6b2d6d6964646c65776172652f762f737461626c652e737667)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)[![Total Downloads](https://camo.githubusercontent.com/2a6c29764bd53bd248b2dc3d228c49afeb6a9f99f7ae24fc131eacd9da637bdd/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f6769746c61622d686f6f6b2d6d6964646c65776172652f646f776e6c6f6164732e737667)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)[![Latest Unstable Version](https://camo.githubusercontent.com/f511df3e0cfeca97bb48e70fc7beb270a534ea1fe04ce1498f1fd6f36338cbd9/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f6769746c61622d686f6f6b2d6d6964646c65776172652f762f756e737461626c652e737667)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)[![License](https://camo.githubusercontent.com/e83d2af90c81db1938e7e7533dd168d634ce4f6812aa8e16c4058c0cb68e204d/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f6769746c61622d686f6f6b2d6d6964646c65776172652f6c6963656e73652e737667)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)[![Build Status](https://camo.githubusercontent.com/8c4d026d1f7f7f2ef7f059b27f1cff28db3ce4541ae66ce5aace4d73cb5e358e/68747470733a2f2f7472617669732d63692e6f72672f746865636f64696e676d616368696e652f6769746c61622d686f6f6b2d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/thecodingmachine/gitlab-hook-middleware)[![Coverage Status](https://camo.githubusercontent.com/ec25796d9c6fbd66b7e5dd60482c75bb2eb4d9f751cb252ec2a9923022b6d9ab/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f746865636f64696e676d616368696e652f6769746c61622d686f6f6b2d6d6964646c65776172652f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/thecodingmachine/gitlab-hook-middleware?branch=master)

Gitlab hook PSR-15 middleware
=============================

[](#gitlab-hook-psr-15-middleware)

This package is a PSR-15 Middleware to receive events sent by a Gitlab webhook and send them to a listener.

It's possible to use directly the hookReceiver to build the event object, but you could check the Gitlab authentification.

How does it work
----------------

[](#how-does-it-work)

The middleware checks the header named X-GITLAB-TOKEN and builds an event object. The object is dispatched to a listener that you must implement.

The middleware takes care of unserializing the payload and provides you with nice PHP objects instead of raw JSON data. It's possible to get the initial array payload with the getPayload() function.

Your listener will receive all events. If you want to listen on a specific event type, you must check the object type.

Event List:

ScopeHookHeaderObjectProjectPush HookPush HookTheCodingMachine\\GitlabHook\\Model\\PushProjectTag Push HookTag Push HookTheCodingMachine\\GitlabHook\\Model\\TagPushProjectNote HookNote Hook*Not implemented*ProjectPipeline HookPipeline HookTheCodingMachine\\GitlabHook\\Model\\PipelineProjectBuild HookBuild HookTheCodingMachine\\GitlabHook\\Model\\BuildGroupProject createdSystem HookTheCodingMachine\\GitlabHook\\Model\\ProjectCreateGroupProject destroyedSystem HookTheCodingMachine\\GitlabHook\\Model\\ProjectDestroyGroupProject renamedSystem HookTheCodingMachine\\GitlabHook\\Model\\ProjectRenameGroupProject transferredSystem HookTheCodingMachine\\GitlabHook\\Model\\ProjectTrasnferGroupNew Team MemberSystem HookTheCodingMachine\\GitlabHook\\Model\\TeamMemberAddGroupTeam Member RemovedSystem HookTheCodingMachine\\GitlabHook\\Model\\TeamMemberRemoveGroupUser createdSystem HookTheCodingMachine\\GitlabHook\\Model\\UserCreateGroupUser removedSystem HookTheCodingMachine\\GitlabHook\\Model\\UserDestroyGroupUser failed loginSystem HookTheCodingMachine\\GitlabHook\\Model\\UserFailedLoginGroupUser renamedSystem HookTheCodingMachine\\GitlabHook\\Model\\UserRenameGroupKey addedSystem HookTheCodingMachine\\GitlabHook\\Model\\KeyCreateGroupKey removedSystem HookTheCodingMachine\\GitlabHook\\Model\\KeyDestroyGroupGroup createdSystem HookTheCodingMachine\\GitlabHook\\Model\\GroupCreateGroupGroup removedSystem HookTheCodingMachine\\GitlabHook\\Model\\GroupDestroyGroupGroup renamedSystem HookTheCodingMachine\\GitlabHook\\Model\\GroupRenameGroupNew Group MemberSystem HookTheCodingMachine\\GitlabHook\\Model\\UserGroupAddGroupGroup Member RemovedSystem HookTheCodingMachine\\GitlabHook\\Model\\UserGroupRemoveGroupPush eventsSystem HookTheCodingMachine\\GitlabHook\\Model\\PushGroupTag eventsSystem HookTheCodingMachine\\GitlabHook\\Model\\TagGroupMerge request eventsSystem HookTheCodingMachine\\GitlabHook\\Model\\MergeRequestGroupRepository Update eventsSystem HookTheCodingMachine\\GitlabHook\\Model\\RepositoryUpdateExample
-------

[](#example)

Listener implementation

```

```

Use without middleware

```
// Create your listener
$listener = new Test\Listerner();

// Register your listener in the main HookReceiver instance
$hookReceiver = new TheCodingMachine\GitlabHook\HookReceiver([$listener]);

// Call handler function to execute check
// $payload is array (json_decode) of data send by Gitlab webhook
// $header is the result of HTTP_X_GITLAB_TOKEN header
$hookReceiver->handle($payload, $header);
```

Use a middleware

```
// Create your listener
$listener = new Test\Listerner();

// Register your listener in the main HookReceiver instance
$hookReceiver = new TheCodingMachine\GitlabHook\HookReceiver([$listener]);

// Create a PSR-3 logger
$logger = new Psr\Log\NullLogger();

// Inject hookReceiver in Gitlab middleware
// You must inject this middleware in the middleware pipe of your favorite framework.
// See your framework documentation on how to do that.
$middleware = new TheCodingMachine\GitlabHook\GitlabHookMiddleware($hookReceiver, 'secret', $logger);
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2487d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

![](https://avatars.githubusercontent.com/u/1847918?v=4)[TheCodingMachine](/maintainers/thecodingmachine)[@thecodingmachine](https://github.com/thecodingmachine)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (13 commits)")

---

Tags

middlewaregitlabHOOK

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thecodingmachine-gitlab-hook-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/thecodingmachine-gitlab-hook-middleware/health.svg)](https://phpackages.com/packages/thecodingmachine-gitlab-hook-middleware)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k13](/packages/tempest-framework)[typo3/cms-core

TYPO3 CMS Core

3713.2M5.0k](/packages/typo3-cms-core)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.5k1.5M83](/packages/mcp-sdk)

PHPackages © 2026

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