Unit 1: Getting started with MVC Laravel framework - Practice Quiz

INT221 — Mvc Programming 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 What does the acronym MVC stand for in software architecture?

A. Model Version Control
B. Method View Class
C. Model View Controller
D. Main View Configuration

2 In the MVC architecture, which component is primarily responsible for managing the data logic and business rules?

A. Router
B. View
C. Controller
D. Model

3 Which component of the MVC framework interacts directly with the user interface and displays data?

A. Kernel
B. Model
C. Controller
D. View

4 Who represents the "Traffic Cop" in the MVC architecture, directing data flow between the Model and the View?

A. Server
B. Database
C. Route
D. Controller

5 If a user sends a request to an MVC application, what is the typical flow of execution?

A.
B.
C.
D.

6 Which of the following is NOT a benefit of using the MVC framework?

A. Separation of concerns
B. Ease of maintenance
C. Increased coupling between logic and presentation
D. Simultaneous development by multiple developers

7 Who is the original creator of the Laravel framework?

A. EllisLab
B. Taylor Otwell
C. Fabien Potencier
D. Rasmus Lerdorf

8 Laravel is built upon which underlying PHP framework components?

A. Yii
B. CodeIgniter
C. Zend
D. Symfony

9 What is the name of the built-in templating engine used in Laravel?

A. Twig
B. Smarty
C. Mustache
D. Blade

10 Which feature in Laravel allows for an expressive, fluent way to interact with databases using Model classes?

A. Doctrine
B. Eloquent ORM
C. PDO Wrapper
D. Active Record

11 What is Composer in the context of PHP and Laravel development?

A. A frontend framework
B. A server configuration tool
C. A dependency manager for PHP
D. A database management tool

12 Which file does Composer primarily use to list project dependencies?

A. composer.json
B. composer.lock
C. package.json
D. config.php

13 When installing Composer globally, which directory allows the composer command to be run from anywhere in the terminal?

A. A directory in the system's
B. The downloads folder
C. The apache htdocs folder
D. The project root

14 Which command is used to install the dependencies defined in composer.json for an existing project?

A. composer get
B. php install
C. composer install
D. composer new

15 What is the purpose of the composer.lock file?

A. It locks the dependencies to specific versions to ensure consistency.
B. It locks the database to prevent writes.
C. It encrypts the PHP source code.
D. It prevents the project from being deleted.

16 Which folder is automatically generated by Composer to store downloaded libraries?

A. packages
B. modules
C. vendor
D. libs

17 Which Composer command allows you to create a new Laravel project from the command line?

A. composer init laravel
B. composer new laravel
C. composer download laravel
D. composer create-project laravel/laravel project-name

18 If the Laravel Installer is globally installed, which command creates a new project?

A. composer laravel new
B. laravel new project-name
C. php laravel new
D. laravel create project-name

19 What is the minimum PHP version required for the latest major versions of Laravel (e.g., Laravel 10/11)?

A. PHP 7.0
B. PHP 5.6
C. PHP 8.1 or higher
D. PHP 7.4

20 Which command is used to start the local development server provided by Laravel?

A. php artisan serve
B. npm run dev
C. composer start
D. php start

21 In a standard Laravel directory structure, where is the entry point (index.php) located?

A. root directory
B. app/
C. resources/
D. public/

22 Which directory contains the User.php model by default in a fresh Laravel installation?

A. resources/models
B. app/Http
C. app/Models
D. database/models

23 Where are the application's configuration files stored?

A. .env
B. config/
C. system/config
D. app/Config

24 Which directory holds the migration files, model factories, and seeds?

A. app/Database
B. storage/
C. resources/
D. database/

25 In which directory would you find your uncompiled views (Blade templates) and raw assets (LESS, SASS, JS)?

A. resources/
B. views/
C. public/
D. app/Views

26 What is the primary purpose of the .env file in the project root?

A. To cache the configuration
B. To list composer dependencies
C. To store environment-specific configuration variables
D. To store database migrations

27 Which Artisan command generates the application key found in the .env file?

A. php artisan init
B. php artisan key:generate
C. php artisan config:cache
D. php artisan make:key

28 Where are the Controller files located within the Laravel directory structure?

A. app/Controllers
B. routes/controllers
C. resources/controllers
D. app/Http/Controllers

29 Which file is responsible for defining web routes in a Laravel application?

A. routes/api.php
B. app/Http/routes.php
C. routes/console.php
D. routes/web.php

30 What is Artisan in Laravel?

A. The database engine
B. The command-line interface (CLI) included with Laravel
C. The template engine
D. The authentication system

31 Which Artisan command allows you to view a list of all available commands?

A. php artisan commands
B. php artisan help
C. php artisan list
D. php artisan show

32 Which command creates a new Controller class named ProductController?

A. php artisan new:controller ProductController
B. php artisan make:controller ProductController
C. php artisan create:controller ProductController
D. php artisan controller:make ProductController

33 To create a migration file for a database change, which command is used?

A. php artisan create:table
B. php artisan db:migration
C. php artisan migration:new
D. php artisan make:migration

34 Which Artisan command executes the pending database migrations?

A. php artisan migrate:run
B. php artisan migrate:install
C. php artisan db:push
D. php artisan migrate

35 What does the php artisan tinker command do?

A. Clears the cache
B. Fixes syntax errors
C. Optimizes the application
D. Opens an interactive REPL (Read-Eval-Print Loop) for the application

36 Which directory contains the autoload.php file generated by Composer?

A. bootstrap/
B. app/
C. vendor/
D. public/

37 What is the purpose of the storage/ directory?

A. Stores the source code
B. Stores compiled Blade templates, file based sessions, and logs
C. Stores the configuration files
D. Stores the database files

38 In 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

39 Which Artisan command would you use to clear the application cache?

A. php artisan cache:clear
B. php artisan clean
C. php artisan clear:cache
D. php artisan flush

40 Laravel uses PSR-4 autoloading. What does this primarily facilitate?

A. Automatic database connection
B. Frontend asset compilation
C. Security encryption
D. Loading classes automatically based on namespaces and file paths

41 What is the function of Middleware in Laravel?

A. To render HTML views
B. To filter HTTP requests entering the application
C. To store database records
D. To compile CSS

42 Which folder serves as the bootstrap location for loading the framework?

A. bootstrap/
B. start/
C. launch/
D. init/

43 Which 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

44 If you see a Whoops, looks like something went wrong page, what setting in .env controls the detail level of this error?

A. APP_KEY
B. APP_DEBUG
C. DB_CONNECTION
D. APP_ENV

45 The App namespace in Laravel usually maps to which directory?

A. application/
B. code/
C. app/
D. src/

46 In MVC, if a logic calculation requires the formula , where should this calculation ideally reside?

A. In the View file
B. In the config folder
C. In the Model or a Service class
D. In the Route definition

47 Which PHP extension is almost always required for Laravel to run (handling strings)?

A. soap
B. gd
C. mbstring
D. imagick

48 To put the application into maintenance mode, which Artisan command is used?

A. php artisan down
B. php artisan maintenance
C. php artisan stop
D. php artisan pause

49 Which directory in Laravel is generally meant to be writable by the web server?

A. storage
B. routes
C. app
D. config

50 What is the syntax to output a variable $name in a Blade view, automatically escaping it?

A. {{ $name }}
B. @echo $name
C. <?= $name ?>
D. { $name }