定制 korditpteltd/kd-cakephp-webhooks 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

korditpteltd/kd-cakephp-webhooks

Composer 安装命令:

composer require korditpteltd/kd-cakephp-webhooks

包简介

KORDIT CakePHP Webhook Plugin

README 文档

README

Build Status License

Plugin containing the vanilla javascript file for the triggering of webhook events implemented on the application level. Plugin also contain the Table file, SQL structure and the default controller for retrieval of webhook table information for execution.

Requirements

  • CakePHP 3.1+

Installation

  • Edit composer.json file by adding the following lines:
"repositories":[
        {
            "type": "git",
            "url": "git@github.com:mohamednizar/kd-cakephp-webhooks.git"
        }
    ]
  • Example composer.json after adding required lines:
{
    "name": "korditpteltd/openemis-phpoe",
    "description": "KORDIT OpenEMIS CORE",
    "homepage": "https://demo.openemis.org/core",
    "type": "project",
    "license": "GPL-2.0",
    "require": {
        "php": ">=5.4.16",
        "cakephp/cakephp": "3.2.6"
    },
    "scripts": {
        "post-install-cmd": "App\\Console\\Installer::postInstall",
        "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "repositories":[
        {
            "type": "git",
            "url": "git@github.com:mohamednizar/kd-cakephp-webhooks.git"
        }
    ]
}
composer require korditpteltd/kd-cakephp-webhooks "*"

Usage

In your app's config/bootstrap.php add:

// In config/bootstrap.php
Plugin::load('Webhook', ['autoload' => true, 'route' => true]);

or using cake's console:

bin/cake plugin load -r --autoload Webhook

Configuration:

You will need to insert the event entries into the webhooks and webhook_events table

webhooks table

id name status url method description modified_user_id modified created_user_id created
1 Application A Logout 1 http://domain.application.com/logout GET To logout from application A null null 1 2017-03-17 03:38:50

webhook_events table

webhook_id event_key
1 logout

Using JavaScript Webhook

In the ctp file you may have the following event implemented:

// load the javascript file from the plugin
$this->Html->script('Webhook.webhook');

// Webhook url link to the webhook controller
$webhookListUrl = [
    'plugin' => 'Webhook',
    'controller' => 'Webhooks',
    'action' => 'listWebhooks'
];

// You may replace \'logout\', with your event name for example \'login\'
echo $this->Html->link('Logout Link', 'http://someurl.com/logout', ['onclick' => 'Webhook.triggerEvent(\''.Router::url($webhookListUrl).'\', [\'logout\']);']);

Using Backend CakePHP Client Service with Shell

$Webhooks = TableRegistry::get('Webhook.Webhooks');

// Setting the 'username' parameter will replace the url with the username that you have specified
$Webhooks->triggerShell('logout', ['username' => $username]);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2020-03-31