1What does the acronym MVC stand for in software architecture?
A.Model Version Control
B.Main View Configuration
C.Method View Class
D.Model View Controller
Correct Answer: Model View Controller
Explanation:
MVC stands for Model View Controller. It is a software design pattern that divides the related program logic into three interconnected elements.
Incorrect! Try again.
2In the MVC architecture, which component is primarily responsible for managing the data logic and business rules?
A.Router
B.Controller
C.Model
D.View
Correct Answer: Model
Explanation:
The Model represents the shape of the data and business logic. It retrieves, stores, and processes data from the database.
Incorrect! Try again.
3Which component of the MVC framework interacts directly with the user interface and displays data?
A.Model
B.View
C.Controller
D.Kernel
Correct Answer: View
Explanation:
The View is responsible for the presentation layer. It displays the data provided by the Controller to the user.
Incorrect! Try again.
4Who represents the "Traffic Cop" in the MVC architecture, directing data flow between the Model and the View?
A.Route
B.Server
C.Controller
D.Database
Correct Answer: Controller
Explanation:
The Controller handles the user's input, interacts with the Model to retrieve data, and passes that data to the View for rendering.
Incorrect! Try again.
5If a user sends a request to an MVC application, what is the typical flow of execution?
A.
B.
C.
D.
Correct Answer:
Explanation:
The request is first intercepted by the Route, which directs it to the appropriate Controller. The Controller interacts with the Model and returns a View.
Incorrect! Try again.
6Which of the following is NOT a benefit of using the MVC framework?
A.Simultaneous development by multiple developers
B.Separation of concerns
C.Ease of maintenance
D.Increased coupling between logic and presentation
Correct Answer: Increased coupling between logic and presentation
Explanation:
MVC promotes loose coupling (not increased coupling) between the logic (Model/Controller) and the presentation (View), making the application easier to maintain and scale.
Incorrect! Try again.
7Who is the original creator of the Laravel framework?
A.EllisLab
B.Fabien Potencier
C.Rasmus Lerdorf
D.Taylor Otwell
Correct Answer: Taylor Otwell
Explanation:
Laravel was created by Taylor Otwell and was first released in June 2011.
Incorrect! Try again.
8Laravel is built upon which underlying PHP framework components?
A.CodeIgniter
B.Symfony
C.Zend
D.Yii
Correct Answer: Symfony
Explanation:
Laravel utilizes many components from the Symfony framework to provide a robust foundation for web application development.
Incorrect! Try again.
9What is the name of the built-in templating engine used in Laravel?
A.Mustache
B.Smarty
C.Blade
D.Twig
Correct Answer: Blade
Explanation:
Blade is the simple, yet powerful templating engine provided with Laravel. It allows the use of plain PHP code in views.
Incorrect! Try again.
10Which feature in Laravel allows for an expressive, fluent way to interact with databases using Model classes?
A.PDO Wrapper
B.Eloquent ORM
C.Doctrine
D.Active Record
Correct Answer: Eloquent ORM
Explanation:
The Eloquent ORM (Object-Relational Mapper) included with Laravel provides a beautiful, simple ActiveRecord implementation for working with databases.
Incorrect! Try again.
11What is Composer in the context of PHP and Laravel development?
A.A server configuration tool
B.A frontend framework
C.A database management tool
D.A dependency manager for PHP
Correct Answer: A dependency manager for PHP
Explanation:
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
Incorrect! Try again.
12Which file does Composer primarily use to list project dependencies?
A.package.json
B.composer.json
C.composer.lock
D.config.php
Correct Answer: composer.json
Explanation:
composer.json describes the dependencies of your project and may contain other metadata as well.
Incorrect! Try again.
13When installing Composer globally, which directory allows the composer command to be run from anywhere in the terminal?
A.The downloads folder
B.The project root
C.A directory in the system's
D.The apache htdocs folder
Correct Answer: A directory in the system's
Explanation:
To access the composer command globally, the Composer executable must be placed in a directory that is part of your system's $PATH environment variable.
Incorrect! Try again.
14Which command is used to install the dependencies defined in composer.json for an existing project?
A.php install
B.composer new
C.composer install
D.composer get
Correct Answer: composer install
Explanation:
The command composer install reads the composer.lock file (or composer.json if the lock file doesn't exist) and installs the specified dependencies.
Incorrect! Try again.
15What is the purpose of the composer.lock file?
A.It locks the database to prevent writes.
B.It encrypts the PHP source code.
C.It prevents the project from being deleted.
D.It locks the dependencies to specific versions to ensure consistency.
Correct Answer: It locks the dependencies to specific versions to ensure consistency.
Explanation:
composer.lock records the exact versions of the packages that were installed. This ensures that every person working on the project uses the exact same versions of the libraries.
Incorrect! Try again.
16Which folder is automatically generated by Composer to store downloaded libraries?
A.vendor
B.libs
C.packages
D.modules
Correct Answer: vendor
Explanation:
Composer installs project dependencies into the vendor directory.
Incorrect! Try again.
17Which Composer command allows you to create a new Laravel project from the command line?
The standard command to create a new project via Composer is composer create-project laravel/laravel [project-name].
Incorrect! Try again.
18If the Laravel Installer is globally installed, which command creates a new project?
A.php laravel new
B.laravel new project-name
C.composer laravel new
D.laravel create project-name
Correct Answer: laravel new project-name
Explanation:
Once the Laravel Installer is installed globally, you can use the command laravel new project-name to quickly scaffold a fresh Laravel installation.
Incorrect! Try again.
19What is the minimum PHP version required for the latest major versions of Laravel (e.g., Laravel 10/11)?
A.PHP 7.4
B.PHP 5.6
C.PHP 7.0
D.PHP 8.1 or higher
Correct Answer: PHP 8.1 or higher
Explanation:
Modern Laravel versions (10.x and 11.x) require modern PHP features, typically requiring PHP 8.1 or PHP 8.2 as a minimum.
Incorrect! Try again.
20Which command is used to start the local development server provided by Laravel?
A.php artisan serve
B.composer start
C.php start
D.npm run dev
Correct Answer: php artisan serve
Explanation:
The command php artisan serve starts a development server at http://localhost:8000.
Incorrect! Try again.
21In a standard Laravel directory structure, where is the entry point (index.php) located?
A.public/
B.root directory
C.app/
D.resources/
Correct Answer: public/
Explanation:
The public directory contains the index.php file, which is the entry point for all requests entering the application.
Incorrect! Try again.
22Which directory contains the User.php model by default in a fresh Laravel installation?
A.app/Models
B.resources/models
C.database/models
D.app/Http
Correct Answer: app/Models
Explanation:
Since Laravel 8, models are placed in the app/Models directory by default.
Incorrect! Try again.
23Where are the application's configuration files stored?
A.system/config
B.app/Config
C.config/
D..env
Correct Answer: config/
Explanation:
The config/ directory contains all of the application's configuration files (e.g., database.php, app.php).
Incorrect! Try again.
24Which directory holds the migration files, model factories, and seeds?
A.database/
B.storage/
C.app/Database
D.resources/
Correct Answer: database/
Explanation:
The database/ directory contains database migrations, model factories, and seeds.
Incorrect! Try again.
25In which directory would you find your uncompiled views (Blade templates) and raw assets (LESS, SASS, JS)?
A.app/Views
B.resources/
C.public/
D.views/
Correct Answer: resources/
Explanation:
The resources/ directory contains the views (inside resources/views) as well as raw assets like CSS and JavaScript.
Incorrect! Try again.
26What is the primary purpose of the .env file in the project root?
A.To store environment-specific configuration variables
B.To store database migrations
C.To list composer dependencies
D.To cache the configuration
Correct Answer: To store environment-specific configuration variables
Explanation:
The .env file stores environment-specific variables like database credentials, app keys, and debug modes, which should not be committed to version control.
Incorrect! Try again.
27Which Artisan command generates the application key found in the .env file?
A.php artisan key:generate
B.php artisan config:cache
C.php artisan init
D.php artisan make:key
Correct Answer: php artisan key:generate
Explanation:
php artisan key:generate sets the APP_KEY value in the .env file, which is used for encryption services.
Incorrect! Try again.
28Where are the Controller files located within the Laravel directory structure?
A.app/Http/Controllers
B.resources/controllers
C.routes/controllers
D.app/Controllers
Correct Answer: app/Http/Controllers
Explanation:
Controllers are located in app/Http/Controllers.
Incorrect! Try again.
29Which file is responsible for defining web routes in a Laravel application?
A.routes/console.php
B.routes/web.php
C.routes/api.php
D.app/Http/routes.php
Correct Answer: routes/web.php
Explanation:
routes/web.php defines routes for the web interface and assigns the web middleware group (providing session state and CSRF protection).
Incorrect! Try again.
30What is Artisan in Laravel?
A.The authentication system
B.The command-line interface (CLI) included with Laravel
C.The template engine
D.The database engine
Correct Answer: The command-line interface (CLI) included with Laravel
Explanation:
Artisan is the command-line interface included with Laravel, providing a number of helpful commands for use while developing.
Incorrect! Try again.
31Which Artisan command allows you to view a list of all available commands?
A.php artisan show
B.php artisan list
C.php artisan help
D.php artisan commands
Correct Answer: php artisan list
Explanation:
php artisan list displays all available Artisan commands.
Incorrect! Try again.
32Which command creates a new Controller class named ProductController?
The command to generate a controller is php artisan make:controller [Name].
Incorrect! Try again.
33To create a migration file for a database change, which command is used?
A.php artisan make:migration
B.php artisan db:migration
C.php artisan create:table
D.php artisan migration:new
Correct Answer: php artisan make:migration
Explanation:
php artisan make:migration is used to create a new migration file.
Incorrect! Try again.
34Which Artisan command executes the pending database migrations?
A.php artisan migrate
B.php artisan migrate:install
C.php artisan db:push
D.php artisan migrate:run
Correct Answer: php artisan migrate
Explanation:
php artisan migrate runs the outstanding migrations to update the database schema.
Incorrect! Try again.
35What does the php artisan tinker command do?
A.Optimizes the application
B.Opens an interactive REPL (Read-Eval-Print Loop) for the application
C.Fixes syntax errors
D.Clears the cache
Correct Answer: Opens an interactive REPL (Read-Eval-Print Loop) for the application
Explanation:
Tinker allows you to interact with your entire Laravel application on the command line, including Eloquent models, jobs, and events.
Incorrect! Try again.
36Which directory contains the autoload.php file generated by Composer?
A.vendor/
B.bootstrap/
C.app/
D.public/
Correct Answer: vendor/
Explanation:
Composer generates the autoloader at vendor/autoload.php, which Laravel includes in public/index.php to load dependencies.
Incorrect! Try again.
37What is the purpose of the storage/ directory?
A.Stores the configuration files
B.Stores the database files
C.Stores compiled Blade templates, file based sessions, and logs
D.Stores the source code
Correct Answer: Stores compiled Blade templates, file based sessions, and logs
Explanation:
The storage/ directory contains logs (storage/logs), compiled view templates (storage/framework/views), and file-based sessions.
Incorrect! Try again.
38In the routes/ directory, what is api.php used for?
A.Defining console commands
B.Defining stateless routes (RESTful) usually for mobile apps or external consumers
C.Defining broadcasting channels
D.Defining routes that return Views
Correct Answer: Defining stateless routes (RESTful) usually for mobile apps or external consumers
Explanation:
routes/api.php contains routes that are intended to be stateless (no sessions) and usually return JSON, suitable for APIs.
Incorrect! Try again.
39Which Artisan command would you use to clear the application cache?
A.php artisan clean
B.php artisan flush
C.php artisan clear:cache
D.php artisan cache:clear
Correct Answer: php artisan cache:clear
Explanation:
php artisan cache:clear is the command used to flush the application cache.
Incorrect! Try again.
40Laravel uses PSR-4 autoloading. What does this primarily facilitate?
A.Automatic database connection
B.Security encryption
C.Loading classes automatically based on namespaces and file paths
D.Frontend asset compilation
Correct Answer: Loading classes automatically based on namespaces and file paths
Explanation:
PSR-4 is a standard for autoloading classes from file paths, allowing you to use classes without manually require or include statements.
Incorrect! Try again.
41What is the function of Middleware in Laravel?
A.To compile CSS
B.To store database records
C.To render HTML views
D.To filter HTTP requests entering the application
Correct Answer: To filter HTTP requests entering the application
Explanation:
Middleware provides a mechanism for inspecting and filtering HTTP requests entering the application (e.g., verifying user authentication).
Incorrect! Try again.
42Which folder serves as the bootstrap location for loading the framework?
A.bootstrap/
B.init/
C.launch/
D.start/
Correct Answer: bootstrap/
Explanation:
The bootstrap/ directory contains the app.php file which bootstraps the framework and configures autoloading.
Incorrect! Try again.
43Which command creates a Model and a Migration simultaneously?
A.php artisan make:model Name --migration
B.php artisan create:model Name -mig
C.php artisan make:model Name -m
D.Both A and B
Correct Answer: Both A and B
Explanation:
You can use the --migration flag or the shorthand -m flag with make:model to generate a migration file alongside the model.
Incorrect! Try again.
44If you see a Whoops, looks like something went wrong page, what setting in .env controls the detail level of this error?
A.APP_ENV
B.APP_DEBUG
C.DB_CONNECTION
D.APP_KEY
Correct Answer: APP_DEBUG
Explanation:
If APP_DEBUG is set to true, Laravel shows detailed stack traces. If false, it shows a generic error page.
Incorrect! Try again.
45The App namespace in Laravel usually maps to which directory?
A.code/
B.src/
C.application/
D.app/
Correct Answer: app/
Explanation:
By default, the App namespace is mapped to the app/ directory in composer.json.
Incorrect! Try again.
46In MVC, if a logic calculation requires the formula , where should this calculation ideally reside?
A.In the View file
B.In the Model or a Service class
C.In the Route definition
D.In the config folder
Correct Answer: In the Model or a Service class
Explanation:
Complex business logic and calculations should reside in the Model or a dedicated service class, not in the View (presentation) or Routes.
Incorrect! Try again.
47Which PHP extension is almost always required for Laravel to run (handling strings)?
A.gd
B.mbstring
C.soap
D.imagick
Correct Answer: mbstring
Explanation:
The mbstring (Multibyte String) extension is required by Laravel to handle string manipulation properly.
Incorrect! Try again.
48To put the application into maintenance mode, which Artisan command is used?
A.php artisan stop
B.php artisan down
C.php artisan pause
D.php artisan maintenance
Correct Answer: php artisan down
Explanation:
php artisan down puts the application into maintenance mode. php artisan up brings it back online.
Incorrect! Try again.
49Which directory in Laravel is generally meant to be writable by the web server?
A.app
B.routes
C.config
D.storage
Correct Answer: storage
Explanation:
The storage and bootstrap/cache directories must be writable by the web server user for Laravel to run.
Incorrect! Try again.
50What is the syntax to output a variable $name in a Blade view, automatically escaping it?
A.<?= $name ?>
B.{{ $name }}
C.{ $name }
D.@echo $name
Correct Answer: {{ $name }}
Explanation:
Blade uses double curly braces {{ $name }} to echo data. This automatically passes the data through PHP's htmlspecialchars function to prevent XSS attacks.