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
Requires
- php: ^8.2
- api-platform/core: ^3.3
- doctrine/persistence: ^3.3
- symfony/framework-bundle: ^6.4
- symfony/messenger: ^6.4
- symfony/property-access: ^6.4
Suggests
- doctrine/doctrine-bundle: Bundle for Doctrine ORM integration
- doctrine/mongodb-odm: Required only if you use MongoDB ODM
- doctrine/mongodb-odm-bundle: Bundle for MongoDB ODM integration
- doctrine/orm: Required only if you use Doctrine ORM
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
- extraProperties (one-liner)
#[Patch( uriTemplate: '/posts/{id}', extraProperties: [ 'write_async' => true, 'transport' => 'low_priority' // optionnel ], status: 202, output: false )] class Post {}
OR
- 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().