1. Go to this page and download the library: Download mamadali/yii2-webhook library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace console\job;
use mamadali\webhook\Module;
use Yii;
use yii\base\BaseObject;
use yii\queue\RetryableJobInterface;
class WebhookJob extends BaseObject implements RetryableJobInterface
{
/**
* @var integer the webhook id
*/
public $webhook_id;
public function execute($queue)
{
/**
* @var Module
*/
$module = Yii::$app->getModule('webhook');
$module->send($this->webhook_id);
}
public function getTtr()
{
return 60;
}
public function canRetry($attempt, $error)
{
return $attempt < 5;
}
}