boone-studios/laravel-idempotency
Composer 安装命令:
composer require boone-studios/laravel-idempotency
包简介
Stripe-style Idempotency-Key middleware for multi-tenant Laravel APIs.
README 文档
README
Stripe-style Idempotency-Key middleware for multi-tenant Laravel APIs.
- Requires an idempotency header on mutating requests
- Cache-locks concurrent retries
- Replays the stored response on matching payload
- Returns
409 Conflictwhen the same key is reused with a different body - Prunes expired records via Eloquent's
Prunable
Requirements
- PHP 8.2+
- Laravel 12 or 13
Installation
composer require boone-studios/laravel-idempotency
php artisan vendor:publish --tag=idempotency-config php artisan vendor:publish --tag=idempotency-migrations php artisan migrate
Configuration
scope_resolver must be configured before you use this middleware. There is
no default implementation — the package ships as null and will throw a
RuntimeException at request time (with a message pointing back to this
config key) if you register the idempotency middleware on a route without
setting it first.
Implement BooneStudios\Idempotency\Contracts\ResolvesIdempotencyScope and set it in config/idempotency.php:
'scope_resolver' => App\Services\TenantContext::class, 'scope_column' => 'tenant_id', // or vendor_id, organization_id, …
Register the middleware:
Route::middleware('idempotency')->post('/orders', …);
Only apply the idempotency middleware to routes where a scope/tenant is
always resolvable (e.g. authenticated, tenant-scoped endpoints). Routes that
legitimately have no tenant yet (e.g. a signup endpoint) should not use this
middleware — resolution failure is treated as a configuration error, not a
"no tenant" case.
License
MIT © Boone Studios, LLC
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-11