jeremka/write-async-bundle

Seamless async write operations for API Platform (ORM & ODM)

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

v0.1.0 2025-05-25 22:19 UTC

This package is auto-updated.

Last update: 2025-05-25 22:36:26 UTC


README

A bundle for API Platform 3 / Symfony 6.4 that ships your write operations (POST, PUT, PATCH) to Symfony Messenger

Why?

  • You don’t want the HTTP request to wait for a flush() that isn’t critical
    (view counters, logs, “seen” flags, …).
  • You just want to say: “Take this payload, deal with it later.”

Quick install

composer require jeremka/write-async-bundle

Make sure you have (at least) one Messenger transport:

#messenger.yaml

framework:
messenger:
transports:
low_priority: '%env(MESSENGER_LOW_DSN)%'

Change the default transport (optional):

write_async.yaml

write_async:
default_transport: low_priority

Enable it on a route

  1. extraProperties (one-liner)
#[Patch(
uriTemplate: '/posts/{id}',
extraProperties: [
'write_async' => true,
'transport'   => 'low_priority' // optionnel
],
status: 202,
output: false
)]
class Post {}

OR

  1. Detached attribute
use Jeremka\WriteAsyncBundle\Attribute\WriteAsyncPatch;

#[WriteAsyncPatch('/posts/{id}', transport: 'low_priority')]
class Post {}

And… that’s it!

No DTO, no custom handler:

  • API Platform still handles validation, deserialization, and security voters.
  • The bundle intercepts the write phase, builds an AsyncWriteMessage, and dispatches it to the queue.
  • The client instantly receives 202 Accepted.
  • A Messenger worker reloads the entity later, applies the diff, and performs the real flush().