tjvb/gitlab-webhooks-receiver-for-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tjvb/gitlab-webhooks-receiver-for-laravel

Composer 安装命令:

composer require tjvb/gitlab-webhooks-receiver-for-laravel

包简介

Receive webhooks from GitLab and store the data in the database.

README 文档

README

Latest Stable Version Pipeline status Coverage report Tested on PHP 8.1 to 8.5 Tested on Laravel 9 to 13 Latest Unstable Version

PHP Version Require Laravel Version Require PHPMD PHPStan ECS

License

GitLab has the option to send webhooks for multiple events that can be used for different purposes. This package handle the receiving, validating and storing of the webhook data. After receiving it will dispatch an event that can be used to do with the data what fits your application.

Installation

  1. You can install the package via composer:

    composer require tjvb/gitlab-webhooks-receiver-for-laravel
    
  2. You can publish and run the migrations with:

php artisan vendor:publish --provider="TJVB\GitLabWebhooks\GitLabWebhooksServiceProvider" --tag="migrations"
php artisan migrate
  1. Listen to the \TJVB\GitLabWebhooks\Events\HookStored::class event. The package store the webhook data and dispatch an event, you can listen to the HookStored event and handle it the way you want. The Laravel documentation can explain more about events and listeners.

  2. Set the GITLAB_WEBHOOK_SECRET env variable (most used version is to set it in the .env file) to have the token you use for your webhook. See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#secret-token for more information.

  3. Create a webhook in GitLab. You can create a webhook in GitLab for your project, group or system. The default url is <application.tld>/gitlabwebhook this can be changed in the configuration from tjvb/gitlab-webhooks-receiver-for-laravel.

  4. Optional configure the package.

Manual register the service provider.

If you disable the package discovery you need to add \TJVB\GitLabWebhooks\GitLabWebhooksServiceProvider::class, to the providers array in config/app.php

Configuration

Customization

You can publish the config file with:

php artisan vendor:publish --provider="TJVB\GitLabWebhooks\GitLabWebhooksServiceProvider" --tag="config"

Security

The default configuration validates the X-Gitlab-Token in the header of the webhook request. It is possible to add multiple values in the config file or disabling the middleware to stop the verification. If you need more validation for the request (as example and i.p. filter) you can add more middleware to the configuration.

Changelog

We (try to) document all the changes in CHANGELOG so read it for more information.

Contributing

You are welcome to contribute, read about it in CONTRIBUTING

Security

If you discover any security related issues, please email info@tjvb.nl instead of using the issue tracker.

Tips

Fast response

As described here GitLab want to have a fast response. That means that it is useful to have a queue driver configured that run the jobs in the background. That means that if you use the sync driver it can happen that the response is to slow, so you get the webhook another time.

Test your webhook

On the GitLab pages with the webhook settings it is possible to test the webhook, use it to verify that everything works as suspected.

Cleanup your hooks

If you don't need the data saved in the webhook it can be a good idea to periodic remove the old data. Depending on the kind of hooks the body can be big. This can be done on the end of your event listener or with a package like spatie/laravel-model-cleanup.

Credits

Thanks to

  • GitLab for the great product, without that this package isn't needed.

License

The MIT License (MIT). Please see License File for more information.

tjvb/gitlab-webhooks-receiver-for-laravel 适用场景与选型建议

tjvb/gitlab-webhooks-receiver-for-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.64k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「gitlab」 「webhook」 「tjvb」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tjvb/gitlab-webhooks-receiver-for-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tjvb/gitlab-webhooks-receiver-for-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 tjvb/gitlab-webhooks-receiver-for-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 19
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-13