Learn Laravel MCQs
Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.
What is the command to view the list of all routes in Laravel?
1) php artisan route:list
2) php artisan list:routes
3) route:list
4) artisan route:list
Answer : php artisan route:list
What is the purpose of the `php artisan optimize` command?
1) Optimize the application
2) Clear cache
3) Clear routes
4) All of the above
Answer : All of the above
How do you send a queued job in Laravel?
1) dispatch()
2) queue()
3) job()
4) sendJob()
Answer : dispatch()
What is the purpose of the `public` directory in Laravel?
1) Store assets
2) Store views
3) Store configuration
4) Store routes
Answer : Store assets
How can you define a custom route in Laravel?
1) Route::get()
2) Route::define()
3) Route::custom()
4) customRoute()
Answer : Route::get()
What is the command to create a new command bus in Laravel?
1) php artisan make:command
2) artisan create:command
3) make:command
4) create:command
Answer : php artisan make:command
How do you access the request headers in Laravel?
1) request()->headers
2) headers()
3) request()->getHeaders()
4) request()->get()
Answer : request()->headers
What is the purpose of the `bootstrap` directory in Laravel?
1) Bootstrap application
2) Load environment
3) Store logs
4) All of the above
Answer : All of the above
How can you create a new route group in Laravel?
1) Route::group()
2) group()
3) Route::setGroup()
4) createGroup()
Answer : Route::group()
What is the command to create a new factory class in Laravel?
1) php artisan make:factory
2) artisan create:factory
3) make:factory
4) create:factory
Answer : php artisan make:factory