gnello/webhook-manager
Composer 安装命令:
composer require gnello/webhook-manager
包简介
Easily associate one or more actions with a specific repository event using webhooks
README 文档
README
WebhookManager easily associates one or more actions with a specific repository event using webhooks.
Services supported: Bitbucket, Github, TravisCI and every custom service.
Installation
It's highly recommended to use composer to install WebhookManager:
composer require gnello/webhook-manager
Read more about how to install and use Composer on your local machine here.
Configuration
On Bitbucket
- Go to the settings of your repository
- Click on "Webhooks" under "Workflow"
- Click on "Add webhook"
- Enter the url of WebhookManager configured on your server (es. https://mysite.com/webhooks)
- Set the triggers
- Save!
On Github
- Go to the settings of your repository
- Click on "Webhooks" under "Options"
- Click on "Add webhook"
- Enter the url of WebhookManager configured on your server (es. https://mysite.com/webhooks)
- Set the content type on
application/json - Set the events
- Save!
On TravisCI
Add this in your .travis.yml file:
notifications:
webhooks: url of WebhookManager configured on your server (es. https://mysite.com/webhooks)
On custom service
This is up to you!
Usage
WebhookManager usage is very simple:
Bitbucket
require '../vendor/autoload.php'; use \Gnello\WebhookManager\App; use \Gnello\WebhookManager\Services\BitbucketService; $webhookManager = new App(); //Action on build passed $webhookManager->add([BitbucketService::BUILD_STATUS_CREATED, BitbucketService::BUILD_STATUS_UPDATED], function(BitbucketService $service) { $payload = $service->getPayload(); if ($payload['commit_status']['state'] == 'SUCCESSFUL') { //do some stuff } }); $webhookManager->listen();
Github
require '../vendor/autoload.php'; use \Gnello\WebhookManager\App; use \Gnello\WebhookManager\Services\GithubService; $webhookManager = new App(['service' => GithubService::class]); //Action on push event $webhookManager->add(GithubService::PUSH, function(GithubService $service) { $payload = $service->getPayload(); //do some stuff }); $webhookManager->listen();
TravisCI
require '../vendor/autoload.php'; use \Gnello\WebhookManager\App; use \Gnello\WebhookManager\Services\TravisCIService; $webhookManager = new App(['service' => TravisCIService::class]); //Action on build passed $webhookManager->add(TravisCIService::PUSH, function(TravisCIService $service) { $payload = $service->getPayload(); if ($payload['state'] === 'passed') { //do some stuff } }); $webhookManager->listen();
Custom service
To use a custom service, you should create a class that implements the \Gnello\WebhookManager\Services\ServiceInterface interface
and then register it on WebhookManager. In WebhookManager options, you should specify that you want to use a custom service.
require '../vendor/autoload.php'; use \Gnello\WebhookManager\App; $webhookManager = new App(['service' => \YourCustomService::class]); //Action on custom event $webhookManager->add('custom_event', function(\YourCustomService $service) { $payload = $service->getPayload(); //do some stuff }); $webhookManager->add('another_event', function(\YourCustomService $service) { //do some stuff }); $webhookManager->listen();
Options
- Bitbucket is the default service, but you can change it as follows:
//github $webhookManager = new \Gnello\WebhookManager\App([ 'service' => \Gnello\WebhookManager\Services\GithubService::class ]); //travis ci $webhookManager = new \Gnello\WebhookManager\App([ 'service' => \Gnello\WebhookManager\Services\TravisCIService::class ]); //custom service $webhookManager = new \Gnello\WebhookManager\App([ 'service' => \Gnello\WebhookManager\Services\YourCustomService::class ]);
- The json_decode of Bitbucket and Github services is set to convert the returned objects into associative arrays. You can change this behavior in this way:
$webhookManager = new \Gnello\WebhookManager\App([ 'json_decode_assoc' => false ]);
Contact
gnello/webhook-manager 适用场景与选型建议
gnello/webhook-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.87k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2017 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bitbucket」 「github」 「webhook」 「travisci」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gnello/webhook-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gnello/webhook-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gnello/webhook-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Handles basic OAuth/OAuth2 authentication along with classes for common services
MediaWiki extension that allows embedding external content, specified by URL, into your wiki pages
Inbox pattern process implementation for your Laravel Applications
Provider-agnostic code review guardian for PHP projects. Works with any PHP project (Symfony, Laravel, Yii, CodeIgniter, etc.) and any Git provider (GitHub, GitLab, Bitbucket, etc.)
Laravel package for the simplification and integration of many of your users most wanted login providers. Installation is a breeze. Never worry about OAuth again.
统计信息
- 总下载量: 5.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-24


