rainerch/yii2-eventhook

There is no license information available for the latest version (1.2.2) of this package.

Forward yii2 events to different targets

Installs: 1 282

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

Type:yii2-extension

1.2.2 2021-03-24 06:52 UTC

This package is auto-updated.

Last update: 2024-04-24 13:28:14 UTC


README

Forward yii2 events to different targets (Web, MQTT ...)

How to use

In your 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
                }
            ]
        ],
    ]
]