The original post: /r/php by /u/seaphpdev on 2025-01-16 19:06:12.

I wanted to introduce an opensource project I authored and use: Syndicate. It’s a framework designed with event driven and message processing needs in mind. It supports common queues and pubsub integrations, has support for deadlettering, and full dependency resolution and injection to your message handlers with a PSR-11 Container instance. It can be pulled into existing frameworks and code bases very easily, has a small memory footprint, uses a graceful shutdown process, and is quick and easy to setup.

It uses a PHP attribute to tag your message handlers, allowing you to define routing criteria and filters:

#[Consume(topic: "users", payload: ["$.event" => "UserCreated", "$.body.role" => ["user", "admin"]])
public function onUserCreated(Message $message, EmailService $emailService): Response
{
    $payload = \json_decode($message->getPayload());

    // There is something fundamentally wrong with this message.
    // Let's push to the deadletter and investigate later.
    if( \json_last_error() !== JSON_ERROR_NONE ){
      return Response::deadletter;
    }

    $receipt_id = $emailService->send(
      $payload->body->name,
      $payload->body->email,
      "templates/registration.tpl"
    );

    // Email send failed, let's try again later...
    if( $receipt_id === null ){
      return Response::nack;
    }

    // All good!
    return Response::ack;
}

I hope you can find a use for it!