Learn Laravel MCQs
Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.
Which command is used to create a request class in Laravel?
1) php artisan make:request
2) php artisan new:request
3) php make request
4) php artisan generate:request
Answer : Option 1
What is the role of Laravel Mix?
1) Handling API requests
2) Compiling and bundling assets
3) Database management
4) Middleware registration
Answer : Option 2
What is a Service Provider in Laravel?
1) A route handler
2) A service container
3) A class that bootstraps application services
4) A middleware
Answer : Option 3
Which method is used to validate a request in Laravel?
1) validate()
2) requestValidate()
3) validateRequest()
4) inputValidate()
Answer : Option 1
How do you share data across all views in Laravel?
1) Using view()->share()
2) Using session()
3) Using with()
4) Using shareAll()
Answer : Option 1
What is the purpose of Laravel Guards?
1) To protect routes
2) To manage authentication
3) To handle sessions
4) To handle requests
Answer : Option 2
What does the `CSRF` middleware protect against?
1) SQL Injection
2) Cross-Site Request Forgery
3) Cross-Site Scripting
4) File Inclusion
Answer : Option 2
Which of the following is used to generate URLs in Laravel?
1) url()
2) route()
3) link()
4) uri()
Answer : Option 2
Which Laravel file handles HTTP middleware?
1) app/Http/Kernel.php
2) app/Middleware.php
3) app/Http/routes.php
4) config/middleware.php
Answer : Option 1
What is the purpose of Laravel queues?
1) Handling file uploads
2) Managing event broadcasting
3) Deferring time-consuming tasks
4) Handling database transactions
Answer : Option 3