承接 gnello/webhook-manager 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

gnello/webhook-manager

Composer 安装命令:

composer require gnello/webhook-manager

包简介

Easily associate one or more actions with a specific repository event using webhooks

README 文档

README

Build Status Latest Stable Version Scrutinizer Code Quality Total Downloads

Bitbucket Github TravisCI

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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 5.87k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-24