1. Go to this page and download the library: Download timacdonald/has-parameters library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
timacdonald / has-parameters example snippets
class ThrottleRequests
{
use HasParameters;
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 1, $prefix = '')
{
//
}
}
// a named rate limiter...
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
// using the rate limiter WITHOUT an alias...
Route::stuff()
->middleware([
ThrottleRequests::with([
'maxAttempts' => 'api',
]),
]);
ThrottleMiddleware::with('admin');
// ✅
ThrottleMiddleware::with(['decayMinutes' => 10]);
// ✅
ThrottleMiddleware::with('foo');
// ❌ fails because 'foo' is not in the allowed string values
ThrottleMiddleware::with(['maxAttempts' => 'ten']);
// ❌ fails because `maxAttempts` must be an int
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.