julianov's avatar

Laravel's throttle configurations

Hello everyone. I am looking to implement throttle in laravel. Observing a possible way would be as follows:

class UserController extends Controller
{

	public function __construct()
	{
           $this->middleware('throttle:60,1')->only(['login', 'signup']);
	}
    //.....
}

As you can see I am implementing it for the Users controller.

But my question is: How can I configure this?

Is it necessary to install the package with

 composer require laravel/throttle

Or is it not necessary? because I already have it installed, if I look at the kernel.php file

protected $middlewareGroups = [
		'web' => [
			EncryptCookies::class,
			AddQueuedCookiesToResponse::class,
			StartSession::class,
			ShareErrorsFromSession::class,
			VerifyCsrfToken::class,
			SubstituteBindings::class,
		],

		'api' => [
			// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
			'throttle:api',
			SubstituteBindings::class,
		],
	];

Is this where I have to set the controller class?

 SubstituteBindings::class,
0 likes
1 reply

Please or to participate in this conversation.