Transports

For a framework-less PHP producer, the core ships three optional reference Transport implementations. They keep the core dependency-free — install only the broker client you use.

The Transport seam

BabelQueue\Contracts\Transport is a single method:

interface Transport
{
    public function publish(string $payload, ?string $queue = null): ?string;
}

$payload is the EnvelopeCodec::encode(...) output. Any broker client can implement it — phpredis (ext-redis) users, for example, can do it in one line (rpush).

RedisTransport

composer require predis/predis
use BabelQueue\Codec\EnvelopeCodec;
use BabelQueue\Transport\RedisTransport;

$transport = new RedisTransport(new Predis\Client('redis://localhost:6379'));

$envelope = EnvelopeCodec::fromJob($job, 'orders');
$transport->publish(EnvelopeCodec::encode($envelope), 'orders');
// a Go / Python / Node consumer reads the identical envelope off "orders"

RedisTransport produces with RPUSH, matching the reliable-queue pattern the other SDKs use.

AmqpTransport

composer require php-amqplib/php-amqplib
use BabelQueue\Transport\AmqpTransport;

$transport = new AmqpTransport(/* php-amqplib connection */);
$transport->publish(EnvelopeCodec::encode($envelope), 'orders');

AmqpTransport declares a durable queue, publishes persistent messages, and sets the contract AMQP properties (type = URN, correlation_id = trace_id, message_id = meta.id, plus x-schema-version / x-source-lang / x-attempts), so consumers can route on properties without parsing the body.

SqsTransport

composer require aws/aws-sdk-php

A produce-side Amazon SQS transport: it sends the canonical envelope as the MessageBody with the §3 MessageAttributes. It is decoupled from the AWS SDK behind a one-method BabelQueue\Transport\SqsClient seam, so wrap a real Aws\Sqs\SqsClient in a one-line adapter:

use BabelQueue\Transport\SqsClient;
use BabelQueue\Transport\SqsTransport;

$adapter = new class (new Aws\Sqs\SqsClient([/* region, credentials */])) implements SqsClient {
    public function __construct(private Aws\Sqs\SqsClient $c) {}
    public function sendMessage(array $args): mixed { return $this->c->sendMessage($args); }
};

$transport = new SqsTransport($adapter, 'https://sqs.eu-central-1.amazonaws.com/123456789012/orders');
$transport->publish(EnvelopeCodec::encode($envelope));
// a Go / Python / Node / Java / .NET consumer reads the identical envelope + attributes

The projected attributes (bq-job = URN, bq-trace-id, bq-message-id, plus bq-schema-version / bq-source-lang / bq-created-at) let a consumer route without decoding the body; FIFO sets MessageGroupId / MessageDeduplicationId.

On Laravel or Symfony you don’t need these — the Laravel driver and the Symfony serializer move the bytes through the framework’s own transport.