1. Go to this page and download the library: Download assegaiphp/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/ */
use Assegai\Common\Interfaces\Queues\QueueInterface;
use Assegai\Core\Attributes\Injectable;
use Assegai\Core\Queues\Attributes\InjectQueue;
final readonly class NotificationJob
{
public function __construct(
public string $recipient,
public string $message,
) {
}
}
#[Injectable]
readonly class NotificationsService
{
public function __construct(
#[InjectQueue('rabbitmq.notifications')] private QueueInterface $queue,
) {
}
public function send(NotificationJob $job): void
{
$this->queue->add($job);
}
}
use Assegai\Core\Attributes\Injectable;
use Assegai\Core\Queues\Attributes\QueueProcessor;
#[Injectable]
#[QueueProcessor('rabbitmq.notifications')]
final class NotificationsProcessor
{
public function process(NotificationJob $job): void
{
// Handle the notification.
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.