1. Go to this page and download the library: Download luoxiaojun1992/yii2-queue 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/ */
class FooController extends UrbanIndo\Yii2\Queue\Worker\Controller
{
public function actionBar($param1, $param2)
{
echo $param1;
}
}
class FooController extends UrbanIndo\Yii2\Queue\Worker\Controller
{
public function actionBar($param1, $param2)
{
try {
// do some stuff
} catch (\Exception $ex) {
\Yii::error('Ouch something just happened');
return false;
}
}
}
public function behaviors()
{
return [
[
'class' => \UrbanIndo\Yii2\Queue\Behaviors\DeferredEventBehavior::class,
'events' => [
self::EVENT_AFTER_VALIDATE => 'deferAfterValidate',
]
]
];
}
public function deferAfterValidate()
{
// do something here
}