Skip to content
Muhammet Şafak edited this page Jun 9, 2026 · 2 revisions

InitPHP Queue — Wiki

Welcome to the official documentation for initphp/queue — the framework-less BabelQueue runtime for plain PHP.

It gives an application that has no Laravel queue or Symfony Messenger of its own the piece babelqueue/php-sdk deliberately leaves to the framework: the consumer loop, retries with back-off and dead-letter routing — plus a database (PDO) transport the core SDK does not ship.

Because it reuses the SDK's canonical { job, trace_id, data, meta, attempts } envelope, the queue you produce and consume here is the same queue a Go, Python, Node or .NET service reads. Messages are routed by a stable URN (urn:babel:orders:created), never a PHP class name.

composer require initphp/queue predis/predis
useBabelQueue\Contracts\InboundMessage;
useInitPHP\Queue\Consumer\{Dispatcher, Worker, WorkerOptions};
useInitPHP\Queue\Contracts\Handler;
useInitPHP\Queue\Producer\Producer;
useInitPHP\Queue\Routing\HandlerMap;
useInitPHP\Queue\Transport\Redis\RedisTransport;
// A handler is mapped to a URN, not a class name.finalclass SendWelcomeEmail implements Handler
{
publicfunctionhandle(InboundMessage$message): void
{
$email = $message->getData()['email'];
// ... send it. Throwing marks the message as failed (retry, then dead-letter).
}
}
$transport = newRedisTransport(newPredis\Client('tcp://127.0.0.1:6379'));
// Produce
(newProducer($transport, 'emails'))
->send('urn:babel:users:registered', ['user_id' => 42, 'email' => 'jane@example.com']);
// Consume$handlers = (newHandlerMap())->register('urn:babel:users:registered', SendWelcomeEmail::class);
$worker = newWorker($transport, newDispatcher($handlers), newWorkerOptions(maxAttempts: 3));
$worker->run('emails');

Where this package sits

Layerbabelqueue/php-sdkInitPHP Queue
Wire format / contractCanonical envelope, URN scheme, validation, dead-letter annotationreuses it
ProducerEnvelopeCodec + a publish TransportProducer facade
Consumer loop— (left to the framework)Worker: reserve → route → ack / retry / dead-letter
TransportsRedis & AMQP (publish only)Redis, AMQP and PDO (publish + consume)

Start here

Use the sidebar to navigate. Every code example on this wiki reflects the real public API of the current release.

Requirements

  • PHP 8.2+
  • babelqueue/php-sdk ^1.0 (installed automatically)
  • A client for your broker: ext-pdo, predis/predis (Redis 6.2+), or php-amqplib/php-amqplib

Clone this wiki locally