1. Go to this page and download the library: Download net-code/laravel-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/ */
net-code / laravel-bus example snippets
use NetCode\Bus\Command\Command;
use NetCode\Bus\Command\CommandHandler;
use NetCode\Bus\Command\HandledBy;
#[HandledBy(CreateUserHandler::class)]
final readonly class CreateUser implements Command
{
public function __construct(public string $email) {}
}
final readonly class CreateUserHandler implements CommandHandler
{
public function __invoke(CreateUser $command): string
{
// ...
return $id;
}
}
use NetCode\Bus\Command\CommandBus;
$id = app(CommandBus::class)->dispatch(new CreateUser('[email protected]'));