承接 alfred-nutile-inc/webhooks 相关项目开发

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

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

alfred-nutile-inc/webhooks

Composer 安装命令:

composer require alfred-nutile-inc/webhooks

包简介

Package to quickly include webhooks in your system

README 文档

README

Install

Setup the provider

'AlfredNutileInc\CoreApp\Webhooks\WebhooksServiceProvider'

Run

php artisan vendor:publish

To publish the mirations

Before you migrate keep reading...

Add to your DatabaseSeeder.php

#database/seeds/DatabaseSeeder.php
/**
 * Used by Webhooks to prevent seed issues
 */
Config::set('seeding', true);

And Webhooks

#database/seeds/DatabaseSeeder.php
Config::set('seeding', true);
$this->call('AppSeeder');
$this->call('WebhooksSeeder');

And copy over vendors/alfred-nutile-inc/webhooks/src/CoreApp/Webhooks/database/seeds/WebhooksSeeder.php to database/seeds

If you want seed data place it in there. There are a couple of examples in there.

@TODO remove the seeder step and make it part of publish

It will end up looking like this

#database/seeds/DatabaseSeeder.php

public function run()
{
	Model::unguard();
	if(Config::get('database.default') != 'sqlite') {
		DB::statement('SET FOREIGN_KEY_CHECKS=0;');
	}

	/**
	 * Used by Webhooks to prevent seed issues
	 */
	Config::set('seeding', true);
	$this->call('AppSeeder');
	$this->call('WebhooksSeeder');

	Config::set('seeding', false);
	if(Config::get('database.default') != 'sqlite') {
		DB::statement('SET FOREIGN_KEY_CHECKS=1;');
	}
}

Just speeds up seed work as the events are ignored

Now you can migrate

php artisan migrate

Add the commands to your Kernal.php

    protected $commands = [
        'AlfredNutileInc\CoreApp\Webhooks\Console\WebhookAddCommand',
        'AlfredNutileInc\CoreApp\Webhooks\Console\WebhookDeleteCommand'
    ];

Command to add and delete webhooks from the db

Add

php artisan core-app:webhook-add http://full.com/post/path 'event.name In Quotes if needed'

Delete

php artisan core-app:webhook-delete

+--------------------------------------+-----------------------------------------------------------+---------------------------------------------------------+
| id                                   | url                                                       | event                                                   |
+--------------------------------------+-----------------------------------------------------------+---------------------------------------------------------+
| 1bc89184-853b-4ac8-873e-294d7be06ed4 | http://foo.com                                            | eloquent.updated: ScreenShooter\Models\ScreenshooterJob |
| bc4de4e1-b90a-401f-8643-0f5fce4ff00b | http://foo.com                                            | foo                                                     |
| mock-1-webhook                       | https://approve-v2.dev:443/callbacks/screenshot_jobs      | eloquent.updated: ScreenShooter\Models\ScreenshooterJob |
| mock-2-webhook                       | https://approve-v2.dev:443/callbacks/screenshot_jobs_test | eloquent.updated: ScreenShooter\Models\ScreenshooterJob |
+--------------------------------------+-----------------------------------------------------------+---------------------------------------------------------+

To see all you can delete

php artisan core-app:webhook-delete foo-uuid

To delete that uuid

How it works

During an event it will look for listeners in the db and if it finds them it will send the results to that callback.

This is Cached so it only hits the db once UNTIL someone adds a new webhook to listen to.

The callbacks are done asynchronously so the delay should not be long.

Adding more events to listen to

Right now this package only listens to public $listening = ['eloquent.*']; which then searches the Webhooks table for event callbacks.

You can make your own WebhooksWrapper class and extend the WebhooksServiceProvider and add more events. Then register your Provider over the above and they will be added as well.

For example this extends the main provider to listen to other events

<?php

namespace App\Providers;

use AlfredNutileInc\CoreApp\Webhooks\WebhooksServiceProvider;

class WebhookExtendedProvider extends WebhooksServiceProvider
{

    public $listening = [
        'eloquent.*',
        '\\App\\Events\\CampaignMadeActive',
        '\\App\\Events\\MetaMasterUpdated'
    ];
}

Return values

  • body will contain the model or event object json_encoded and serialized, the url, and the environment

Notes

Move over test with this before going solo on this package

alfred-nutile-inc/webhooks 适用场景与选型建议

alfred-nutile-inc/webhooks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.95k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2015 年 03 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 alfred-nutile-inc/webhooks 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 13
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-12