1. Go to this page and download the library: Download shipsaas/safe-dispatcher 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/ */
shipsaas / safe-dispatcher example snippets
use SaasSafeDispatcher\Bus\SafeDispatcher;
class RegisterService
{
public function __construct(public SafeDispatcher $dispatcher) {}
public function register(): void
{
$user = User::create();
$job = new SendEmailToRegisteredUser($user);
$this->dispatcher->dispatch($job);
}
}
use SaasSafeDispatcher\Traits\SafeDispatchable;
class SendEmailToRegisteredUser implements ShouldQueue
{
use SafeDispatchable;
}
SendEmailToRegisteredUser::safeDispatch($user);