Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Idempotency Bundle Laravel Package

conejerock/idempotency-bundle

View on GitHub
Deep Wiki
Context7

Custom extractor

A typical case may be that the requesting party does not make the request with an idempotent key. Or the key is sent in two or more different fields.

Or, perhaps, you only want to cached responses to a certain resource.

If you need a more specific way to extract the key, you can create a custom exctractor, inheriting from the AbstractExtractor class, and adding in the configuration the extractor option as follows:

# config/packages/idempotency.yaml
idempotency:
    name: api
    extractor: 'App\Extractor\MyCustomExtractor::class'

And the class MyCustomExtractor::class as follow:

<?php
declare(strict_types=1);

namespace App\Extractor;

use Conejerock\IdempotencyBundle\Extractor\AbstractExtractor;
use Symfony\Component\HttpFoundation\Request;

class MyCustomExtractor extends AbstractExtractor
{
    public function extract(Request $request): ?string
    {
       return $request->getMethod()."-".$request->query->get('resourceId');
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin