The Missing check on Laravel Request Unicity.

Overview

Motivation

This laravel package will allow you to execute a code once in the current request based on the key provided.

Installation

composer require inani/laravel-same-request

You will(for L5) need to register the service provider in the config/app.php .

return [
       /*
         * Package Service Providers...
         */

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        Inani\UniqueRequest\UniqueRequestServiceProvider::class, // <=== HERE
];

You will need to use the middleware or binding it globally in your app/Http/Kernel.php

return [
        'api' => [
                'throttle:120,1',
                'bindings',
                PreventCache::class,
                GetJwtFromCookie::class,
                AddUniqueIdentifier::class
         ],
];

Usage

    for ($i= 0; $i < 2; $i++){
        $greeting = request()->once(function (){
            info('entred once');
            return 'hello';
        }, 'greeting');
    }

    $goodbye = request()->once(function (){
        return 'Saynoara';
    }, 'bye');

    $goodbye = request()->once(function (){
        return 'ByeBye';
    }, 'bye');

    return [$greeting, $goodbye];
You might also like...
Voyager - The Missing Laravel Admin
Voyager - The Missing Laravel Admin

Voyager - The Missing Laravel Admin Made with ❤️ by The Control Group Website & Documentation: https://voyager.devdojo.com/ Video Tutorial Here: https

Voyager - The Missing Laravel Admin
Voyager - The Missing Laravel Admin

Voyager - The Missing Laravel Admin Made with ❤️ by The Control Group Website & Documentation: https://voyager.devdojo.com/ Video Tutorial Here: https

🧑‍🔬 The missing assertions for your views in your Laravel applications.
🧑‍🔬 The missing assertions for your views in your Laravel applications.

Laravel View Assertions The missing assertions for your views in your Laravel applications. Installation You'll have to follow a couple of simple step

The missing laravel helper that allows you to inspect your eloquent queries with it's bind parameters

Laravel Query Inspector The missing laravel helper that allows you to ispect your eloquent queries with it's bind parameters Motivations Let's say you

The Missing Laravel Commands

Made with ❤️ by SecTheater Foundation Artify CheatSheet will be availble soon Laravel is a great framework and it provides us the ability to create ou

Voyager - The Missing Laravel Admin
Voyager - The Missing Laravel Admin

Voyager - The Missing Laravel Admin Made with ❤️ by The Control Group Website & Documentation: https://voyager.devdojo.com/ Video Tutorial Here: https

Missing pet flyer - Laravel 4 application

Laravel 4.0 Application - Pet Flyer generator Features This is the source of http://missingpetflyer.com that is deployed to Pagodabox. This applicatio

The missing PHP 5.3+ calendar management library.

CalendR CalendR is an Object Oriented Calendar management library on top of PHP5.3+ Date objects. You can use it to deal with all your needs about cal

🍺 The missing package manager for macOS (or Linux)

Homebrew Features, usage and installation instructions are summarised on the homepage. Terminology (e.g. the difference between a Cellar, Tap, Cask an

Support for many missing PostgreSQL specific features
Support for many missing PostgreSQL specific features

Laravel supports many different databases and therefore has to limit itself to the lowest common denominator of all databases. PostgreSQL, however, of

⚡️ A WordPress plugin to quickly send a 404 for missing static files

Static 404 A WordPress plugin to quickly send a 404 for missing static files. Quickly output a 404 for static files that aren't found, rather than loa

Missing data types for PHP. Highly extendable.
Missing data types for PHP. Highly extendable.

Neverending data validation can be exhausting. Either you have to validate your data over and over again in every function you use it, or you have to rely it has already been validated somewhere else and risk potential problems.

Copy missing items from grocy to bring
Copy missing items from grocy to bring

Copy Grocy "Missing Products" to BRING List Build Container First build the container: docker build -t grocy-to-bring . Run Container Insert your Groc

Iterators - The missing PHP iterators.

PHP Iterators Description The missing PHP iterators. Features CachingIteratorAggregate ClosureIterator: ClosureIterator(callable $callable, array $arg

The RSS feed for websites missing it
The RSS feed for websites missing it

RSS-Bridge is a PHP project capable of generating RSS and Atom feeds for websites that don't have one. It can be used on webservers or as a stand-alon

Provides the missing range field for the Filament forms.
Provides the missing range field for the Filament forms.

The missing range field for the Filament forms. Installation You can install the package via composer: composer require yepsua/filament-range-field Pu

Check the health of your Laravel app
Check the health of your Laravel app

Check the health of your Laravel app This repo can be used to scaffold a Laravel package. Follow these steps to get started: Press the "Use template"

.env vars check for Spatie's Laravel Health

Custom check for Spatie's Laravel Health - Ensure every .env variable you need has a value

Check Exchange Rates for any currency in Laravel.
Check Exchange Rates for any currency in Laravel.

Exchange Check exchange rates for any currency in Laravel If your app supports multi-currency, you'll no doubt need to check exchange rates. There are

Releases(1.2.3)
Owner
Inani El Houssain
Tech Lead at @leyton-group
Inani El Houssain
Query caching for Laravel

Query caching for Laravel

Dwight Watson 1k Dec 30, 2022
LaraCache is an ORM based package for Laravel to create, update and manage cache items based on model queries

LaraCache Using this package, you can cache your heavy and most used queries. All you have to do is to define the CacheEntity objects in the model and

Mostafa Zeinivand 202 Dec 19, 2022
Simple artisan command to debug your redis cache. Requires PHP 8.1 & Laravel 9

?? php artisan cache:debug Simple artisan command to debug your redis cache ?? Installation You can install the package via composer: composer require

Juan Pablo Barreto 19 Sep 18, 2022
A small CLI tool to check missing dependency declarations in the composer.json and module.xml

Integrity checker Package allows to run static analysis on Magento 2 Module Packages to provide an integrity check of package. Supported tools: Compos

run_as_root GmbH 13 Dec 19, 2022
This tool check syntax of PHP files faster than serial check with fancier output.

PHP Parallel Lint This application checks syntax of PHP files in parallel. It can output in plain text, colored text, json and checksyntax formats. Ad

PHP Parallel lint 202 Dec 22, 2022
CRUD php application to check in and check out employees and show daily building occupation

CRUD php application to check in and check out employees and show daily building occupation. Employees are required to self check their temperature and tick a checkbox to specify whether their temperature is below 38°C else they are invited to stay home. (Implemented in php with bootstrap4 for styling and datatable jquery plugin for table formatting and additional features).

null 2 Feb 20, 2022
PHP Parallel Lint - This tool check syntax of PHP files faster than serial check with fancier output

PHP Parallel Lint This application checks syntax of PHP files in parallel. It can output in plain text, colored text, json and checksyntax formats. Ad

PHP Parallel lint 156 Apr 24, 2022
This Package helps you in laravel application to log all desired activity for each request from request entry point to generate response at a single snapshot.

Laravel Scenario Logger This Package helps you in laravel application to log all desired activity for each request from request entry point to generat

Mehrdad Mahdian 6 Sep 27, 2021
Csrf Component provides Cross Site Request Forgery protection by comparing provided token with session token to ensure request validity.

Csrf Component Csrf Component provides Cross Site Request Forgery protection by comparing provided token with session token to ensure request validity

ATOMASTIC 3 Mar 12, 2022
HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

HttpRequestor from Patienceman HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast

Manirabona Patience 2 Aug 26, 2022