inani/ laravel-same-request
缺失Laravel对请求唯一性的检查。
1.3.0
2023-10-23 09:07 UTC
Requires
- illuminate/support: ~5|~6|~7|~8|~9|~10
Requires (Dev)
- fzaninotto/faker: ~1.4
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-09-26 09:08:19 UTC
README
此Laravel包允许您根据提供的键在当前请求中执行一次代码。
安装
composer require inani/laravel-same-request
您需要在config/app.php
中注册服务提供者(对于L5)。
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 ];
您需要在app/Http/Kernel.php
中使用中间件或将其全局绑定
return [ 'api' => [ 'throttle:120,1', 'bindings', PreventCache::class, GetJwtFromCookie::class, AddUniqueIdentifier::class ], ];
使用方法
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];