rainerch/yii2-eventhook

此包的最新版本(1.2.2)没有提供许可证信息。

将 yii2 事件转发到不同的目标

安装量: 1,635

依赖项: 0

建议者: 0

安全: 0

星标: 0

分支: 0

类型:yii2-extension

1.2.2 2021-03-24 06:52 UTC

This package is auto-updated.

Last update: 2024-09-24 14:16:24 UTC


README

将 yii2 事件转发到不同的目标(Web、MQTT...)

如何使用

在您的 config.php 中

<?php
$config = [
    'bootstrap' = ['webhook'],
    'components' = [
        'webhook' => [
            'class' => 'rainerch\eventhook\HttpPost',
            'events' => [
                [['\yii\db\ActiveRecord'], ['afterInsert', 'afterUpdate'], [
                    'url' => 'https://example.com/myAwesomeWebhook'
                ]],
                ['app\MyModel', 'afterInsert', [
                    'url' => 'https://example.com/MyAwesomeModelWebhook'
                ]],
                function($sender) {
                    // use closure as filter, return true if you want to send the webhook
                }
            ]
        ],
    ]
]