一键导入
idempotency
Install, configure, and apply the Laravel Idempotency package in Laravel applications when you need retry-safe POST, PUT, or PATCH endpoints.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Install, configure, and apply the Laravel Idempotency package in Laravel applications when you need retry-safe POST, PUT, or PATCH endpoints.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | idempotency |
| description | Install, configure, and apply the Laravel Idempotency package in Laravel applications when you need retry-safe POST, PUT, or PATCH endpoints. |
Use this skill when a Laravel application needs retry-safe write requests, idempotency keys, or controller attributes.
wendelladriel/laravel-idempotency correctlycomposer require wendelladriel/laravel-idempotencyphp artisan vendor:publish --tag=idempotency-config when the app needs non-default behavioridempotency.ttlidempotency.requiredidempotency.scopeidempotency.headeridempotency.inputPrefer route middleware when:
Use the controller attribute when:
only or except targeting is usefulUse the package middleware class:
use WendellAdriel\Idempotency\Http\Middleware\Idempotent;
Route::post('/orders', StoreOrderController::class)
->middleware(Idempotent::class);
When the endpoint needs overrides, use Idempotent::using(...):
Route::post('/payments', ChargePaymentController::class)
->middleware(Idempotent::using(
ttl: 600,
required: false,
scope: \WendellAdriel\Idempotency\Enums\IdempotencyScope::Ip,
header: 'X-Idempotency-Key',
));
The package reads the key from the configured header first. When the header does not contain a non-empty string, it falls back to the configured request input, which defaults to _idempotency_key. Use the request input for standard HTML forms that cannot set custom headers.
Use the @idempotency Blade directive to render the configured hidden input with a generated key:
<form method="POST" action="/orders">
@csrf
@idempotency
</form>
Pass an existing key with @idempotency($key) when the application generates or stores the key elsewhere.
Use the package attribute on classes or methods:
use WendellAdriel\Idempotency\Attributes\Idempotent;
#[Idempotent]
class OrderController
{
public function store()
{
// ...
}
}
Use method-level attributes to override class-level defaults:
use WendellAdriel\Idempotency\Enums\IdempotencyScope;
#[Idempotent]
class PaymentController
{
#[Idempotent(ttl: 600, scope: IdempotencyScope::Global)]
public function store()
{
// ...
}
}
user when authenticated users should not collide with each other; guests fall back to IPip for guest-heavy flows where IP segmentation is enoughglobal when the same key should replay across users or IPsWendellAdriel\Idempotency\Idempotency::key() when the server needs to create keysPOST, PUT, or PATCH requests with the same key replay the original response422409 with Retry-After: 1required is disabledUse the maintenance commands when debugging replay behavior, purging entries after a compromised key, or inspecting cache usage during incident response.
php artisan idempotency:listphp artisan idempotency:list --scope=user --id=5
php artisan idempotency:list --scope=global
php artisan idempotency:list --limit=20
# remove everything (prompts unless --force is passed)
php artisan idempotency:forget --all --force
# scoped removal
php artisan idempotency:forget --scope=user --id=5 --force
php artisan idempotency:forget --scope=ip --id=1.2.3.4 --force
php artisan idempotency:forget --scope=global --force
# purge everything tied to a single client-provided key
php artisan idempotency:forget --key=checkout-1 --force
Read before executing:
user, ip, and global