PHP code example of quellabs / canvas-scheduler-rabbitmq
1. Go to this page and download the library: Download quellabs/canvas-scheduler-rabbitmq 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/ */
quellabs / canvas-scheduler-rabbitmq example snippets
use Quellabs\Contracts\Scheduler\QueueableInterface;
class SendEmailJob implements QueueableInterface {
public function __construct(
private int $userId,
private string $template
) {}
public function handle(): void {
// Send the email
}
public function getPayload(): array {
return [
'userId' => $this->userId,
'template' => $this->template,
];
}
public function getTimeout(): int {
return 30;
}
public function getMaxRetries(): int {
return 3;
}
}
use Quellabs\Contracts\Scheduler\QueueInterface;
class UserController {
public function __construct(private QueueInterface $queue) {}
public function register(Request $request): Response {
// Handle registration...
$this->queue->push(new SendEmailJob(
userId: $user->id,
template: 'welcome'
));
return new Response('Registered');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.