oneduo/laravel-gitlab-webhook-client
Composer 安装命令:
composer require oneduo/laravel-gitlab-webhook-client
包简介
A client to handle incoming Gitlab webhook requests
README 文档
README
This a tiny client that allows you to listen to Gitlab webhooks in your Laravel application. You may use the events dispatched and use the data they provide to perform actions in your application.
Webhook types supported:
- Push Events
- Tag Events
- Issue Events
- Comments Events
- Merge request Events
- Wiki page Events
- Pipeline Events
- Job Events
- Deployment Events
- Release Events
- Subgroup Events
- Feature flag Events
- Release events
Installation
You can install the package via composer:
composer require oneduo/laravel-gitlab-webhook-client
You can publish the config file with:
php artisan vendor:publish --tag="gitlab-webhook-client-config"
This is the contents of the published config file:
<?php declare(strict_types=1); return [ /* |-------------------------------------------------------------------------- | Webhook route |-------------------------------------------------------------------------- | | Here you may choose to enable the default webhook route provided by | the package. If you decide to disable this, you should manually register | the route in your application and implement the event dispatching logic | within your route. | | This registers the following route: POST /gitlab-webhook | | default: true */ 'route_enabled' => true, /* |-------------------------------------------------------------------------- | Secret Token Middleware |-------------------------------------------------------------------------- | | You may set the value of the secret token defined in Gitlab. | The package will validate all incoming requests against this given token, | and reject all unauthorized requests. | | Set the value to NULL to disable the middleware. | | default: null */ 'secret_token' => env('GITLAB_WEBHOOK_SECRET_TOKEN'), ];
Usage
Setting up Gitlab
To get started, you must first set up a webhook in your Gitlab project.
You may follow the official documentation provided
here https://docs.gitlab.com/ee/user/project/integrations/webhooks.html.
Setting up the webhook url
By default, when the route_enabled config is set to true, the package automatically registers a route to handle all
incoming webhook requests.
It is registered as POST /gitlab-webhook and you may inspect your routes using the php artisan route:list command.
Note If you wish to implement your own route, please take a look at the
WebhookControllerto implement a similar logic to dispatch events.
When Gitlab sends a webhook request to your application, the package will dispatch an event based on the type of webhook received.
For instance, if Gitlab sends a merge request webhook, the package will dispatch a MergeRequestEvent event.
You may register your own listener like this:
class EventServiceProvider extends ServiceProvider { /** * The event to listener mappings for the application. * * @var array<class-string, array<int, class-string>> */ protected $listen = [ MergeRequestEvent::class => [ MergeRequestEventListener::class, ], ]; }
All the events are type-hinted to provide easy access to the event attributes and data:
<?php declare(strict_types=1); namespace App; use App\Gitlab\Events\MergeRequestEvent; class MergeRequestEventListener { public function handle(MergeRequestEvent $event): void { logger()->info('New merge request event received'); logger()->info($event->mergeRequest->title); logger()->info('By: ' . $event->mergeRequest->last_commit->author->email); } }
Note You may use individual event listeners for each event type or use a single listener that listens to
WebhookEventContractthat will catch all events dispatched.
Note Please note that some attributes and data is considered nullable, and you must implement the necessary null checks on these values.
Deduplication
Webhook deduplication is not guaranteed by Gitlab. You may use the uuid property on each event to handle deduplication
within your application.
Security
Each event exposes the headers provided by Gitlab. You may use the X-Gitlab-Token header to verify the request
authenticity against the secret token you have set in your Gitlab project settings.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
oneduo/laravel-gitlab-webhook-client 适用场景与选型建议
oneduo/laravel-gitlab-webhook-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.22k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 05 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「oneduo」 「laravel-gitlab-webhook-client」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oneduo/laravel-gitlab-webhook-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oneduo/laravel-gitlab-webhook-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oneduo/laravel-gitlab-webhook-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is my package laravel-recaptcha-enterprise
A LaunchDarkly driver for Laravel Pennant
Provides configurable and customizable Stripe-like keys for your Eloquent models
PHP SDK for the GitHub REST API – OpenAPI based and fully typed for seamless integration
Alfabank REST API integration
Laravel query builder order by field method
统计信息
- 总下载量: 2.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-24