LARAVEL Middleware MCQ
Laravel MCQ- Home
- Tutorials
- Laravel
- Middleware
- Multiple Choice Question
(1) Kernel.php file located in __________ directory.
A) app/http
B) app/http/controllers
C) app/http/Middleware
D) routes/
Explanation
Kernel.php is located in app/http directory in Laravel 5.7 and above.
(2) Alias name for registering new middleware is used in _________ list.
A) $middleware
B) $middlewareGroups
C) $routeMiddleware
D) $middlewarePriority
Explanation
Alias are used in $routeMiddleware list to register middleware.
(3) In how many ways a new middleware can be register in kernel.php
A) 1
B) 2
C) 3
D) 4
Explanation
There are four ways to register newly created middleware. 1. $middleware, 2. $middlewareGroups, 3. $routeMiddleware, 4. $middlewarePriority
(4) Which of the following list is used to register middleware for specific routes ?
A) $routeMiddleware
B) $routingMiddleware
C) $middleware
D) $middlewareGroups
Explanation
$routeMiddleware list is used to register newly created middleware for particular routes.
(5) Which artisan command is used to create new middleware ?
A) make:middleware
B) create:middleware
C) make::middleware
D) created::middleware
Explanation
make:middleware command is used to create new middleware in application. The complete syntax for creating new middleware is php artisan make:middleware middleware_name
(6) Which of the folloiwing file is used to register newly created middleware.
A) middlware
B) kernel
C) config
D) setmiddleware
Explanation
Kernel.php file is used to register newly created routes, This file is located in \app\Http\kernel.php