1. Go to this page and download the library: Download mmalessa/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/ */
mmalessa / command-bus example snippets
class ExampleCommand
{
private $id;
private $name;
public function __construct(int $id, string $name)
{
$this->id = $id;
$this->name = $name;
}
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
}
class ExampleCommandHandler
{
public function handle(ExampleCommand $command)
{
echo "Example command handler" . PHP_EOL;
printf("ID: %s\n", $command->getId());
printf("Name: %s\n", $command->getName());
}
}
use Mmalessa\CommandBus\CommandBus;
$commandBus = new CommandBus();
$commandBus->subscribe(new ExampleCommandHandler());
// The command class is automatically detected based on the type of parameter
// in the handler 'handle' method.
$command = ExampleCommand::create(1, "Silifon");
$commandBus->handle($command);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.