Laravel is a free and open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller architectural pattern and based on Symfony.
Laravel MCQs: This section contains multiple-choice questions and answers on the various topics of Laravel. Practice these MCQs to test and enhance your skills on Laravel.
List of Laravel MCQs
1. Laravel is a ____ framework?
- PHP
- JavaScript
- Python
- React
Answer: A) PHP
Explanation:
Laravel is a PHP framework.
2. Does Laravel follow the MVC concept?
- Yes
- No
Answer: A) Yes
Explanation:
Laravel is powerful MVC PHP framework.
3. Does Laravel follow the object-oriented approach?
- Yes
- No
Answer: A) Yes
Explanation:
Laravel follows the object-oriented approach.
4. Does PHP follow the object-oriented approach?
- No
- Yes
Answer: B) Yes
Explanation:
Yes, PHP is object-oriented programming language.
5. Who developed Laravel?
- Yes
- Taylor Otwell
- Tim Berners-Lee
- Guillermo Rauch
- Brendan Eich
Answer: B) Taylor Otwell
Explanation:
Laravel is developed by Taylor Otwell.
ADVERTISEMENT
6. Laravel is ____ framework?
- Frontend
- Backend
Answer: B) Backend
Explanation:
Laravel is a backend framework.
7. Is Laravel an open-source?
- Yes
- No
Answer: A) Yes
Explanation:
Laravel is an open-source framework.
8. All dependencies are specified in the ____ file, which is located in the source folder?
- Root
- Config
- composer.json
Answer: C) composer.json
Explanation:
All dependencies are specified in the composer.json file, which is located in the source folder.
9. Command line interface used in Laravel is called ____.
- Command Prompt
- CLI
- Composer
- Artisan
Answer: D) Artisan
Explanation:
Command line interface used in Laravel is called Artisan.
10. How many built-in libraries does Laravel provides?
- 30
- 20
- 100
- 50
Answer: B) 20
Explanation:
Laravel provides 20 built-in libraries.
ADVERTISEMENT
11. What is the name of the ORM used in Laravel?
- Artisan
- Composer
- Hibernate
- Eloquent
Answer: D) Eloquent
Explanation:
Eloquent is an object relational mapper (ORM) that comes with the Laravel framework by default.
12. The database definitions and structure are kept in PHP code using ____.
- Redis
- Template engine
- Schema Builder
Answer: C) Schema Builder
Explanation:
The database definitions and structure are kept in PHP code using Schema Builder.
13. Which template language does Laravel use?
- Blade
- Cron
- Template engine
- Command Bus
Answer: A) Blade
Explanation:
Laravel has a simple yet powerful templating engine called Blade.
14. ____ installed on your system before you install Laravel.
- Browser
- Composer
- Eloquent
- None of the above
Answer: B) Composer
Explanation:
Composer installed on your system before you install Laravel.
15. Which folder in Laravel includes the entire source code of the project?
- Events
- Public
- App
- Console
Answer: C) App
Explanation:
App includes the entire source code of the project.
ADVERTISEMENT
16. ____ contains the artisan commands required by Laravel.
- Events
- Public
- Jobs
- Console
Answer: D) Console
Explanation:
Console contains the artisan commands required by Laravel.
17. What is the extension of the folder which includes all the events for the project?
- .php
- .txt
- .xml
- .laravel
Answer: A) .php
Explanation:
.php is the extension of the folder which includes all the events for the project.
18. What is the name of the file which handles all the exceptions?
- Exception_methods.php
- Handle.php
- Exceptions.php
Answer: B) Handle.php
Explanation:
handle.php is the name of the file which handles all the exceptions.
19. Which folder in Laravel contains model, controllers and views defined for the specific directories?
- Events
- Public
- Jobs
- Http
Answer: D) Http
Explanation:
Http folder in Laravel contains model, controllers and views defined for the specific directories.
20. The ____ directory stores the actions that have been queued for the Laravel application?
- Events
- Public
- Jobs
- Http
Answer: C) Jobs
Explanation:
The Jobs directory stores the actions that have been queued for the Laravel application.
ADVERTISEMENT
21. ____ are PHP classes that contain the authorization logic.
- Policies
- Providers
- Http
Answer: A) Policies
Explanation:
Policies are PHP classes that contain the authorization logic.
22. The database directories in Laravel, includes how many sub-directories?
- 2
- 3
- 4
- 5
Answer: B) 3
Explanation:
The database directories in Laravel, includes 3 many sub-directories: Seeds, Migrations, Factories.
23. Which of the following folder includes the classes needed for database unit testing?
- Seeds
- Migrations
- Factories.
Answer: A) Seeds
Explanation:
Seeds folder includes the classes needed for database unit testing.
24. To produce a huge number of data records, ____folder is needed?
- Seeds
- Migrations
- Factories.
Answer: C) Factories.
Explanation:
To produce a huge number of data records, factories folder is needed.
25. Which of the following folder is the root folder and helps in initializing the Laravel application?
- Events
- Public
- Resources
- Http
Answer: B) Public
Explanation:
Public folder is the root folder and helps in initializing the Laravel application.
26. The name standard for test case classes is ____, and it is based on the functionality of the class?
- Toggle case
- Uppercase
- Lowercase
- Camel case
Answer: D) Camel case
Explanation:
The name standard for test case classes is camel case, and it is based on the functionality of the class.
27. The ____ folder includes all the composer dependencies?
- Events
- Public
- Vendor
- Resources
Answer: C) Vendor
Explanation:
The Vendor folder includes all the composer dependencies.
28. ____are those that offer your web application with a list of web services.
- Events
- Environment variables
- Routing
- Resources
Answer: B) Environment variables
Explanation:
Environment variables are those that offer your web application with a list of web services.
29. In which of the following file, environment variables are declared?
- .environment
- .env_varibales
- .env
Answer: C) .env
Explanation:
In .env file, environment variables are declared.
30. The configuration settings are cached using which of the following command?
- Config_cache
- Cache
- Config
- Config:cache
Answer: D) Config:cache
Explanation:
The configuration settings are cached using config:cache command.
ADVERTISEMENT
31. All requests in Laravel are mapped using ____.
- Data binding
- Routes
- ORM
Answer: B) Routes
Explanation:
All requests in Laravel are mapped using routes.
32. ____serves as a link between a request and its response.
- Data binding
- Routes
- Middleware
Answer: C) Middleware
Explanation:
Middleware serves as a link between a request and its response.
33. How many types of middleware are there in Laravel?
- 5
- 4
- 3
- 2
Answer: D) 2
Explanation:
In Laravel there are two types of middleware:
- Global Middleware
- Route Middleware
34. Every HTTP request made by the application will trigger the ____ Middleware.
- Global
- Route
Answer: A) Global
Explanation:
Every HTTP request made by the application will trigger the Global Middleware.
35. The ____ Middleware will be assigned to a specific route.
- Global
- Route
Answer: B) Route
Explanation:
The Route Middleware will be assigned to a specific route.
36. Which of the following property is used to register Global middleware?
- $global
- $route
- $middleware
- $routemiddleware
Answer: C) $middleware
Explanation:
$middleware property is used to register Global Middleware.
37. Which of following property is used to register route specific middleware?
- $global
- $route
- $middleware
- $routemiddleware
Answer: D) $routemiddleware
Explanation:
$routemiddleware property is used to register route specific middleware.
38. The terminate method in the middleware takes how many arguments?
- 2
- 4
- 5
- 6
Answer: A) 2
Explanation:
The terminate method will receive two arguments $request and $response.
39. Which of the following keyword enables developers to condense the namespace?
- Name
- Taken
- Use
- Namespace
Answer: C) Use
Explanation:
The use keyword enables developers to condense the namespace.
40. Which of the following functions as a bridge between Views and Models?
- Objects
- Data binding
- Route
- Controller
Answer: D) Controller
Explanation:
Controller functions as a bridge between Views and Models.
41. ____Controllers allow you to design a single route to handle all of the controller’s actions?
- Implicit controller
- Restful resource controller
- Resource controller
Answer: A) Implicit controller
Explanation:
Implicit Controllers allow you to design a single route to handle all of the controller’s actions.
42. To get the specified URI, we use the “____” method.
- Is
- Use
- Path
- Link
Answer: C) Path
Explanation:
To get the specified URI, use the “path” method.
43. In how many ways you can retrieve the Input values in Laravel?
- 1
- 2
- 3
- 4
Answer: B) 2
Explanation:
There are two ways we can retrieve the input values:
- Using the input() method
- Using the properties of Request instance
44. How many arguments does Input method takes in Laravel?
- 1
- 2
- 3
- 4
Answer: A) 1
Explanation:
Input method in Laravel takes only one argument.
45. How many arguments does Cookie() method takes?
- 1
- 2
- 3
- 4
Answer: C) 3
Explanation:
Cookie() method takes three arguments:
- First: Name of the cookie
- Second: Value of the cookie
- Third: Duration of the cookie
46. The ____function may be used to connect the response to headers?
- Header()
- Router()
- Namespace()
- Response()
Answer: A) Header()
Explanation:
The header() function may be used to connect the response to headers.
47. Which of the following separates the application logic and the presentation logic?
- Model
- View
- Controller
Answer: B) View
Explanation:
Views separates the application logic and the presentation logic.
48. How many databases does Laravel supports?
- 5
- 6
- 4
- 7
Answer: C) 4
Explanation:
Laravel currently supports following 4 databases −
- MySQL
- Postgres
- SQLite
- SQL Server
49. Which of the following log channel driver in Laravel discards all log messages?
- Syslog
- Slack
- Single
- Null
Answer: D) Null
Explanation:
Null log channel driver in Laravel discards all log messages.
50. ____ feature of Laravel supports different language to be used in application.
- Localization
- Globalization
- Language-app
Answer: A) Localization
Explanation:
Localization feature of Laravel supports different language to be used in application.
51. ____ are used to store information about the user across the requests.
- Localization
- Memcached
- Config
- Sessions
Answer: D) Sessions
Explanation:
Sessions are used to store information about the user across the requests.
52. How many arguments does the Get() method takes in session?
- 2
- 1
- 4
- 5
Answer: B) 1
Explanation:
Get() method takes only one argument i.e., key to get the session data.
53. In Laravel which method is used to store the data in session?
- Get()
- Post()
- Put()
Answer: C) Put()
Explanation:
Put() method is used to store the data in session.
54. How many arguments does put() method takes?
- 2
- 3
- 4
- 5
Answer: A) 2
Explanation:
Put() method takes two arguments: Key and value.
55. Which of the following method is used to delete an item from the session?
- Delete (0
- Expire()
- Forget()
- Del()
Answer: C) Forget()
Explanation:
The forget() method is used to delete an item from the session.
56. Is forget() method and Pull() method the same thing?
- Yes
- No
Answer: B) NO
Explanation:
The forget() and pull() methods vary in that the forget() method does not return the value of the session, but the pull() function returns it and deletes it from the session.
57. Laravel uses free feature-rich library ____ to send emails?
- SwiftMailer
- Emailer
- Mails
Answer: A) SwiftMailer
Explanation:
Laravel uses free feature-rich library SwiftMailer to send emails.
58. Which of the following artisan command creates all the listeners?
- event:
- event:listener
- event:generate
Answer: C) event:generate
Explanation:
event:generate, artisan command creates all the listeners.
59. ____ provide a “static” interface to classes that are available in the application service container?
- Events
- Facades
- Views
Answer: B) Facades
Explanation:
Facades provide a “static” interface to classes that are available in the application service container.
60. Are facades and helper function the same thing?
- Yes
- No
Answer: A) Yes
Explanation:
There is no difference between facades and helper function.
61. Laravel ____ are a set of interfaces that define the framework’s basic services?
- Facades
- Controller
- Contracts
- All of the above
Answer: C) Contracts
Explanation:
Laravel Contracts are a set of interfaces that define the framework’s basic services.
62. What do you mean by CSRF in Laravel?
- Cross site forgery accounts
- Criss spot forgery account
- Cross site forgery attacks
Answer: C) Cross site forgery attacks
Explanation:
CSRF stands for cross site forgery attacks.
63. Does Laravel generate CSRF token automatically?
- Yes
- No
Answer: A) Yes
Explanation:
Laravel creates a CSRF “token” automatically for each active user session controlled by the application.
64. The process of recognising the user credentials is known as ____?
- Authorization
- Identity management
- Authentication
Answer: C) Authentication
Explanation:
The process of recognising the user credentials is known as authentication.
65. Which of the following commands is needed to construct forms and the controllers connected with them in order to accomplish authentication?
- php make:auth
- php artisan make:auth
- artisan make:auth
Answer: B) php artisan make:auth
Explanation:
php artisan make:auth, command is needed to construct forms and the controllers connected with them in order to accomplish authentication.
66. ____is the controller used for authentication.?
- HomeController
- CallController
- DefaultController
Answer: A) HomeController
Explanation:
HomeController is the controller used for authentication.
67. In ____, the system or web application determines whether authenticated users may access the resources they are attempting to access or request?
- Authorization
- Identity management
- Authentication
Answer: A) Authorization
Explanation:
In authorization, the system or web application determines whether authenticated users may access the resources they are attempting to access or request.
68. Is authorization and authentication the same thing?
- Yes
- No
Answer: B) NO
Explanation:
Authentication entails verifying the authenticity of the user credentials, whereas authorization involves verifying the rights and permissions that an authenticated user has over the resources.
69. ____are basic closures that assess whether or not a user is permitted to execute a particular operation?
- Gates
- Policies
Answer: A) Gates
Explanation:
Gates are basic closures that assess whether or not a user is permitted to execute a particular operation.
70. Policies classes arrange authorization logic around a certain model or resource?
- Gates
- Policies
Answer: B) Policies
Explanation:
Policies classes arrange authorization logic around a certain model or resource.
71. Which of the following command is used to create a policy?
- Create:policy
- Insert:Policy
- Make:policy
- Generate:policy
Answer: C) Make:policy
Explanation:
The make:policy Artisan command can be used to create a policy.
72. Which of the following command is used to get a list of all possible Artisan commands?
- Display
- Show
- View
- List
Answer: D) List
Explanation:
You may use the list command to get a list of all possible Artisan commands.
73. ____ allows you to use the command line to interact with your whole Laravel application, including Eloquent models, jobs, events, and more?
- Tinker
- Artisan
- REPL
Answer: A) Tinker
Explanation:
Tinker allows you to use the command line to interact with your whole Laravel application, including Eloquent models, jobs, events, and more.
74. ____ is the act of turning plain text to a message using techniques that prevents any third party from reading the information?
- Decryption
- Encryption
Answer: B) Encryption
Explanation:
Encryption is the act of turning plain text to a message using techniques that prevents any third party from reading the information.
75. Which AES algorithm is used by Laravel?
- AES-256
- AES-128
- Both
- Only A
- Only B
Answer: C) Both
Explanation:
Laravel’s encrypter uses OpenSSL to provide AES-256 and AES-128 encryption.
76. The process of converting a string of characters into a shorter fixed value or key that represents the original string is known as ____?
- Decryption
- Encryption
- Hashing
Answer: C) Hashing
Explanation:
The process of converting a string of characters into a shorter fixed value or key that represents the original string is known as hashing.
77. Is Error 403 and Error 404 the same kind of errors?
- Yes
- No
Answer: B) NO
Explanation:
The difference between 403 and 404 errors is that 404 is displayed when a user attempts to access an unknown resource or URL, whereas 403 error, as shown in the screenshot above, is presented when an unauthorized user attempts to access the website.
78. How many attributes does artisan command expectsQuestion includes?
- 1
- 3
- 4
- 2
Answer: D) 2
Explanation:
expectsQuestion includes two attributes.: One with question and other with an apiKeySecret.
79. How many parameters does Paginate method takes?
- 1
- 3
- 4
- 2
Answer: A) 1
Explanation:
Paginate method takes only 1 parameter i.e., number of items to be displayed in one page.
80. Which of the following are the alternatives of Laravel?
- Angular.
- CodeIgniter.
- CakePHP.
- Phalcon.
- All of the above
Answer: E) All of the above
Explanation:
Following are the alternatives of Laravel:
- Angular.
- CodeIgniter.
- CakePHP.
- Phalcon.
81. Which of the following is the oldest broadcasting organization who uses Laravel?
- Netflix
- BBC
- IBM
Answer: C) BBC
Explanation:
BBC is the oldest broadcasting organization who uses Laravel, other companies who uses Laravel are: 9GAG, Pfizer, TourRadar, and Crowdcube.