In Laravel middleware acts as a middleman between request and response. Middleware is a type of HTTP requests filtering mechanism.
Example: If a user is not authenticated and it is trying to access the dashboard then, the middleware will redirect that user to the login page.

Get ready to be answerable to this question. This is a favorite Laravel Interview Questions of many interviewers. Don’t let this question waste the opportunity. Read it twice.



// Syntax
php artisan make:middleware MiddelwareName

// Example
php artisan make:middleware UserMiddelware

Now UserMiddelware.php file will create in app/Http/Middleware

Suggest An Answer

No suggestions avaliable!