1. Go to this page and download the library: Download trntv/yii2-command-bus 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 ReportCommand extends Object implements BackgroundCommand, SelfHandlingCommand
{
use BackgroundCommandTrait;
public $someImportantData;
public function handle($command) {
// do what you need
}
}
'components' => [
'queue' => [
// queue config
],
'commandBus' =>[
...
'middlewares' => [
[
'class' => '\trntv\bus\middlewares\QueuedCommandMiddleware',
// 'delay' => 3, // You can set default delay for all commands here
]
]
...
]
]
class HeavyComputationsCommand extends Object implements QueuedCommand, SelfHandlingCommand
{
use QueuedCommandTrait;
public function handle() {
// do work here
}
}
$command = new HeavyComputationsCommand();
Yii::$app->commandBus->handle($command)
class SomeCommand implements SelfHandlingCommand
{
public function handle($command) {
// do what you need
}
}
$command = Yii::$app->commandBus->handle($command);
php composer.phar
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.