1. Go to this page and download the library: Download vshf/php-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/ */
vshf / php-bus example snippets
$bus = new \VSHF\Bus\Bus();
$command = new MyCommand($someParamsIfAny);
$bus->dispatch($command);
$bus->addMiddleware(MyMiddleware::class);
class MyMiddleware implements \VSHF\Bus\MiddlewareInterface {
public function before() : void
{
// Code that runs before executing the command. It has access to:
// $this->$command
// $this->agent_type
// $this->agent_id
$this->next(); // If this call is omitted, the command execution is prevented.
}
public function after() : void
{
// Code that runs after executing the command. It has access to:
// $this->$command
// $this->agent_type
// $this->agent_id
}
}
// greater number means delayed execution, default is 0
$bus->addMiddleware(MyMiddleware::class, 99);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.