jeremka/write-async-bundle
最新稳定版本:v0.1.0
Composer 安装命令:
composer require jeremka/write-async-bundle
包简介
Seamless async write operations for API Platform (ORM & ODM)
README 文档
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().
统计信息
- 总下载量: 184
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-25