{"id":18929562,"url":"https://github.com/thecodingmachine/gitlab-hook-middleware","last_synced_at":"2026-02-28T11:10:24.757Z","repository":{"id":57067863,"uuid":"146440699","full_name":"thecodingmachine/gitlab-hook-middleware","owner":"thecodingmachine","description":"A PSR-15 middleware to handle Gitlab hooks","archived":false,"fork":false,"pushed_at":"2019-09-10T10:01:24.000Z","size":52,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-12-06T16:10:08.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-28T11:58:17.000Z","updated_at":"2019-10-25T12:11:08.000Z","dependencies_parsed_at":"2022-08-24T10:20:12.712Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/gitlab-hook-middleware","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/gitlab-hook-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fgitlab-hook-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fgitlab-hook-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fgitlab-hook-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fgitlab-hook-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/gitlab-hook-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fgitlab-hook-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29931532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T09:58:13.507Z","status":"ssl_error","status_checked_at":"2026-02-28T09:57:57.047Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:33:38.187Z","updated_at":"2026-02-28T11:10:24.740Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/gitlab-hook-middleware/v/stable.svg)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)\n[![Total Downloads](https://poser.pugx.org/thecodingmachine/gitlab-hook-middleware/downloads.svg)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)\n[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/gitlab-hook-middleware/v/unstable.svg)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)\n[![License](https://poser.pugx.org/thecodingmachine/gitlab-hook-middleware/license.svg)](https://packagist.org/packages/thecodingmachine/gitlab-hook-middleware)\n[![Build Status](https://travis-ci.org/thecodingmachine/gitlab-hook-middleware.svg?branch=master)](https://travis-ci.org/thecodingmachine/gitlab-hook-middleware)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/gitlab-hook-middleware/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/thecodingmachine/gitlab-hook-middleware?branch=master)\n\nGitlab hook PSR-15 middleware\n=============================\n\nThis package is a PSR-15 Middleware to receive events sent by a Gitlab webhook and send them to a listener.\n\nIt's possible to use directly the hookReceiver to build the event object, but you could check the Gitlab authentification.\n\nHow does it work\n----------------\n\nThe middleware checks the header named X-GITLAB-TOKEN and builds an event object. The object is dispatched to a listener \nthat you must implement.\n\nThe middleware takes care of unserializing the payload and provides you with nice PHP objects instead of raw JSON data.\nIt's possible to get the initial array payload with the getPayload() function.\n\nYour listener will receive all events. If you want to listen on a specific event type, you must check the object type.\n\nEvent List:\n\n|Scope|Hook|Header|Object|\n|-----|----|------|------|\n|Project|Push Hook|Push Hook|TheCodingMachine\\GitlabHook\\Model\\Push|\n|Project|Tag Push Hook|Tag Push Hook|TheCodingMachine\\GitlabHook\\Model\\TagPush|\n|Project|Note Hook|Note Hook|*Not implemented*|\n|Project|Pipeline Hook|Pipeline Hook|TheCodingMachine\\GitlabHook\\Model\\Pipeline|\n|Project|Build Hook|Build Hook|TheCodingMachine\\GitlabHook\\Model\\Build|\n|Group|Project created|System Hook|TheCodingMachine\\GitlabHook\\Model\\ProjectCreate|\n|Group|Project destroyed|System Hook|TheCodingMachine\\GitlabHook\\Model\\ProjectDestroy|\n|Group|Project renamed|System Hook|TheCodingMachine\\GitlabHook\\Model\\ProjectRename|\n|Group|Project transferred|System Hook|TheCodingMachine\\GitlabHook\\Model\\ProjectTrasnfer|\n|Group|New Team Member|System Hook|TheCodingMachine\\GitlabHook\\Model\\TeamMemberAdd|\n|Group|Team Member Removed|System Hook|TheCodingMachine\\GitlabHook\\Model\\TeamMemberRemove|\n|Group|User created|System Hook|TheCodingMachine\\GitlabHook\\Model\\UserCreate|\n|Group|User removed|System Hook|TheCodingMachine\\GitlabHook\\Model\\UserDestroy|\n|Group|User failed login|System Hook|TheCodingMachine\\GitlabHook\\Model\\UserFailedLogin|\n|Group|User renamed|System Hook|TheCodingMachine\\GitlabHook\\Model\\UserRename|\n|Group|Key added|System Hook|TheCodingMachine\\GitlabHook\\Model\\KeyCreate|\n|Group|Key removed|System Hook|TheCodingMachine\\GitlabHook\\Model\\KeyDestroy|\n|Group|Group created|System Hook|TheCodingMachine\\GitlabHook\\Model\\GroupCreate|\n|Group|Group removed|System Hook|TheCodingMachine\\GitlabHook\\Model\\GroupDestroy|\n|Group|Group renamed|System Hook|TheCodingMachine\\GitlabHook\\Model\\GroupRename|\n|Group|New Group Member|System Hook|TheCodingMachine\\GitlabHook\\Model\\UserGroupAdd|\n|Group|Group Member Removed|System Hook|TheCodingMachine\\GitlabHook\\Model\\UserGroupRemove|\n|Group|Push events|System Hook|TheCodingMachine\\GitlabHook\\Model\\Push|\n|Group|Tag events|System Hook|TheCodingMachine\\GitlabHook\\Model\\Tag|\n|Group|Merge request events|System Hook|TheCodingMachine\\GitlabHook\\Model\\MergeRequest|\n|Group|Repository Update events|System Hook|TheCodingMachine\\GitlabHook\\Model\\RepositoryUpdate|\n\n\nExample\n-------\n\nListener implementation\n```php\n\u003c?php\nnamespace Test;\n\nclass Listener implements HookListenerInterface {\n    /**\n     * @param \\TheCodingMachine\\GitlabHook\\EventInterface $event\n     */\n     public function onEvent(EventInterface $event) {\n         // Compute Push event\n         if($event instanceof TheCodingMachine\\GitlabHook\\Model\\Push::class) {\n             // Display before\n             echo $event-\u003egetBefore();\n             // Display the project name\n             echo $event-\u003egetProject()-\u003egetName();\n         }\n         // Compute MergeRequest event\n         if($event instanceof TheCodingMachine\\GitlabHook\\Model\\MergeRequest::class) {\n             // Display target branch (this is in object_attributes)\n             echo $event-\u003egetTargetBranch();\n             // Get initial payload\n             var_dump($event-\u003egetPayload());\n         }\n     }\n}\n?\u003e\n``` \n\nUse without middleware\n\n```php\n\n// Create your listener\n$listener = new Test\\Listerner();\n\n// Register your listener in the main HookReceiver instance\n$hookReceiver = new TheCodingMachine\\GitlabHook\\HookReceiver([$listener]);\n\n// Call handler function to execute check\n// $payload is array (json_decode) of data send by Gitlab webhook\n// $header is the result of HTTP_X_GITLAB_TOKEN header \n$hookReceiver-\u003ehandle($payload, $header);\n```\n\nUse a middleware\n```php\n\n// Create your listener\n$listener = new Test\\Listerner();\n\n// Register your listener in the main HookReceiver instance\n$hookReceiver = new TheCodingMachine\\GitlabHook\\HookReceiver([$listener]);\n\n// Create a PSR-3 logger\n$logger = new Psr\\Log\\NullLogger(); \n\n// Inject hookReceiver in Gitlab middleware\n// You must inject this middleware in the middleware pipe of your favorite framework.\n// See your framework documentation on how to do that.\n$middleware = new TheCodingMachine\\GitlabHook\\GitlabHookMiddleware($hookReceiver, 'secret', $logger);\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fgitlab-hook-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fgitlab-hook-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fgitlab-hook-middleware/lists"}