1. Go to this page and download the library: Download babelqueue/symfony 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 BabelQueue\Symfony\Contracts\PolyglotMessage;
final class OrderCreated implements PolyglotMessage
{
public function __construct(public int $orderId) {}
public function getBabelUrn(): string
{
return 'urn:babel:orders:created';
}
public function toPayload(): array
{
return ['order_id' => $this->orderId];
}
public static function fromBabelPayload(array $data): static
{
return new self((int) $data['order_id']);
}
}
// produce — a normal Messenger dispatch
$bus->dispatch(new OrderCreated(1042));
// consume — a normal Messenger handler, routed by message class
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler]
final class OnOrderCreated
{
public function __invoke(OrderCreated $message): void
{
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.