wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

laravel part1

Total questions: 23

Worksheet time: 12mins

Name
Class
Date
1.

What command is used to create a new Laravel project?

a)

laravel new project

b)

composer create-project laravel/laravel project

c)

php artisan make:project

d)

laravel create project

2.

Which file in a Laravel project contains the application's environment-specific configuration?

a)

config/app.php

b)

.env

c)

bootstrap/app.php

d)

routes/web.php

3.

What is the purpose of the routes/web.php file in a Laravel application?

a)

To define API routes

b)

) To define web routes

c)

To configure database connections

d)

To set environment variables

4.

What does the php artisan serve command do?

a)

Runs database migrations

b)

Clears the application cache

c)

Compiles frontend assets

d)

Starts a development server

5.

Which directory contains the controllers in a Laravel application?

a)

app/Controllers

b)

app/Http/Controllers

c)

resources/Controllers

d)

routes/Controllers

6.

How do you generate a new controller in Laravel?

a)

php artisan make:controller

b)

php artisan create:controller

c)

php artisan generate:controller

d)

php artisan new:controller

7.

What is the default database management system (DBMS) used by Laravel?

a)

MySQL

b)

SQLite

c)

PostgreSQL

d)

MariaDB

8.

Which command is used to run database migrations in Laravel?

a)

php artisan migrate

b)

php artisan db:migrate

c)

php artisan migration:run

d)

php artisan database:migrate

9.

What is the purpose of the resources/views directory?

a)

To store Blade template files

b)

To store configuration files

c)

To store compiled assets

d)
  • To store language files

10.

Which artisan command is used to create a new model in Laravel?

a)
  • php artisan make:model

b)

php artisan create:model

c)

php artisan generate:model

d)

php artisan new:model

11.

What is a middleware in Laravel?

a)

A filter for HTTP requests

b)

A type of view

c)

A type of controller

d)

A type of route

12.

Which method in a controller handles a GET request to a specific URL in Laravel?

a)

show()

b)

get()

c)

index()

d)

retrieve()

13.

How do you define a named route in Laravel?

a)

Route::get('/home', 'HomeController@index')->path('home');

b)

Route::get('/home', 'HomeController@index')->url('home');

c)

Route::get('/home', 'HomeController@index')->route('home');

d)

Route::get('/home', 'HomeController@index')->name('home');

14.

What is the purpose of the artisan command in Laravel?

a)

To perform various command-line tasks

b)

To run the web server

c)

To manage user authentication

d)

To compile Blade templates

15.

Which method is used to redirect to another URL in a Laravel controller?

a)

redirect()

b)

return redirect()

c)

return route()

d)

route()

16.

Which of the following is NOT a valid HTTP status code?

a)

200

b)

404

c)

500

d)

700

17.

Which method defines a one-to-one relationship in an Eloquent model?

a)

hasMany()

b)

hasOne()

c)
  • belongsTo()

d)

belongsToMany()

18.

What is eager loading in Laravel?

a)

Loading related models using a single query.

b)

Loading models without relationships

c)

Loading models with lazy loading

d)

Loading models on demand

19.

What is the purpose of model factories in Laravel?

a)

To create fake data for testing

b)

To define database migrations

c)

To handle model relationships

d)

To manage model validations

20.

Which method is used to perform a soft delete on an Eloquent model?

a)

delete()

b)

destroy()

c)

forceDelete()

d)

softDelete()

21.

How do you restore a soft-deleted model in Laravel?

a)

restore()

b)

revive()

c)

undelete()

d)

revert()

22.

What package is commonly used for debugging Laravel applications in development mode?

a)

Laravel Telescope

b)

Laravel DebugBar

c)

Laravel Cashier

d)

Laravel Mix

23.

Which Blade directive is used to include a view within another view?

a)

@include

b)

@yield

c)

@section

d)

@extends