A simple package for idempotent requests in Laravel.

Related tags

Miscellaneous replay
Overview

📽 Replay

A simple package for handling idempotent requests in Laravel.

Any routes using the Replay middleware will check for whether an incoming request meets certain criteria, and if so, it will cache the request for 24 hours so that any subsequent requests will always receive the same response.

Installation

Require Replay using Composer:

composer require kayrunm/replay

Usage

To get started with using Replay, all you need to do is attach the Replay middleware to whichever routes you wish to allow for idempotent requests. For example:

use Kayrunm\Replay\Replay;

Route::post('/account/{account}/transfer', [TransferController::class, 'store'])->middleware(Replay::class);

Configuration

Replay works out-of-the-box, but you can configure it further to fit your needs. To get started, publish the config file with the following command:

php artisan vendor:publish --tag="replay"

Strategies

This package uses the strategy pattern for both determining which requests should be idempotent and for storing their responses in the cache. You can view the default strategies for these below:

If you decide to implement your own strategies for either of the above, simply update the config file with the relevant strategies, for example:

'strategies' => [

    'caching' => \Acme\CustomCacheStrategy::class,
    
    'idempotency' => \Acme\CustomIdempotencyStrategy::class,
    
],

You can also customise the header used for the idempotency key (which is used in DefaultIdempotencyStrategy, which you could change to use a query parameter, if you wished), as well as how long an idempotent request should stay in the cache (which is used in DefaultCacheStrategy)

Licence

Replay is an open-sourced software licensed under the MIT license.

You might also like...
A Simple Linode SDK built for Laravel with @JustSteveKing laravel-transporter package

linode client A Simple Linode client built for Laravel with @JustSteveKing laravel-transporter package Installation You can install the package via co

A simple laravel package for wallet implementation

wallet A simple laravel package for wallet implementation. This package can basically be plugged into a laravel project and it will handle wallet impl

Simple laravel package for 2C2P Payment Gateway.

Laravel 2C2P Payment Gateway Simple laravel package for 2C2P Payment Gateway. Installation You can install the package via composer: composer require

Traits used primarily in the v6 package but also available as a helper package for applications

Phalcon Traits This package contains traits with methods that are used for Phalcon v6 onward. It can also be useful to others that want short snippets

This package is aimed to be a simplistic PHP workflow package that works in a similar fashion to GitHub Actions.

Workflow This package is aimed to be a simplistic PHP workflow package that works in a similar fashion to GitHub Actions. Installation To install this

Quick package/plugin/component (repo) lookup for your favourite package managers
Quick package/plugin/component (repo) lookup for your favourite package managers

Package Managers (Download latest release) Package Repo Search Quick package/plugin/component (repo) lookup for your favourite package managers.

This package was created to provide simple way to manipulate arrays in PHP

PHP Collections This package was created to provide simple way to manipulate arrays in PHP. The package was inspired by the Laravel Collections.

Simple PHP package for add two numbers

Sum Simple PHP package for add two numbers Installation To get the latest version of Sum, simply require the project using Composer: composer require

A simple package for working with money.

Money A simple package for working with money. Main features: Simple API Livewire integration Custom currency support Highly customizable formatting R

Comments
  • Add locking to stop concurrent requests from succeeding

    Add locking to stop concurrent requests from succeeding

    Added functionality to create a lock for the incoming request before the request has finished.

    Before this PR it would be possible for two requests with the same key to be received at the same time, and both would successfully execute. With the locking, one of the requests will now fail and, by default, return a 409 Conflict response.

    Also, some housekeeping

    opened by kayrunm 0
Owner
Kieran Marshall
Kieran Marshall
An alternative to run cron jobs that uses simple HTTP requests

SilverStripe Simple Jobs An alternative to run cron jobs that uses simple HTTP requests. This module require SilverStripe CronTask. Why? Configuring c

Thomas Portelange 1 Jul 4, 2022
Issue tracking application extending GitHub's issues and pull requests for the Joomla! project.

Requirements The issue tracker application requires a server running: PHP 7.2 or 7.3 PHP's ext/curl and ext/intl should also be installed MySQL 5.5.3

Joomla! 68 Oct 27, 2022
⚓️ Easily test HTTP webhooks with this handy tool that displays requests instantly.

Webhook.site With Webhook.site, you instantly get a unique, random URL that you can use to test and debug Webhooks and HTTP requests, as well as to cr

Webhook.site 3.7k Jan 9, 2023
It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help

[Magento 1 Extension] It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help (without any php code).

Vladimir Fishchenko 62 Apr 1, 2022
Issue trackers, feature requests, and translation for all of my NamelessMC products

NamelessMC Products In this repository you can find current issues for each of my NamelessMC products, progress on solving them, feature requests, and

Coldfire 1 Mar 25, 2022
Easily build Eloquent queries from API requests

Build Eloquent queries from API requests This package allows you to filter, sort and include eloquent relations based on a request. The QueryBuilder u

Spatie 3.5k Jan 7, 2023
Magento - Attach log correlation ID (aka Trace ID) to requests, monlog entries, and New relic transactions

magento2-log-correlation-id Magento 2 log correlation id for PHP requests/processes and magento logs. This is useful when debugging issues on a produc

Ampersand 13 Dec 15, 2022
salah eddine bendyab 18 Aug 17, 2021
Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.

Laravel Blog Have you worked with Wordpress? Developers call this package wordpress-like laravel blog. Give our package a Star to support us ⭐ ?? Inst

Binshops 279 Dec 28, 2022