Font size
Worksheetslaravel part1
Total questions: 23
Worksheet time: 12mins
What command is used to create a new Laravel project?
laravel new project
composer create-project laravel/laravel project
php artisan make:project
laravel create project
Which file in a Laravel project contains the application's environment-specific configuration?
config/app.php
.env
bootstrap/app.php
routes/web.php
What is the purpose of the routes/web.php file in a Laravel application?
To define API routes
) To define web routes
To configure database connections
To set environment variables
What does the php artisan serve command do?
Runs database migrations
Clears the application cache
Compiles frontend assets
Starts a development server
Which directory contains the controllers in a Laravel application?
app/Controllers
app/Http/Controllers
resources/Controllers
routes/Controllers
How do you generate a new controller in Laravel?
php artisan make:controller
php artisan create:controller
php artisan generate:controller
php artisan new:controller
What is the default database management system (DBMS) used by Laravel?
MySQL
SQLite
PostgreSQL
MariaDB
Which command is used to run database migrations in Laravel?
php artisan migrate
php artisan db:migrate
php artisan migration:run
php artisan database:migrate
What is the purpose of the resources/views directory?
To store Blade template files
To store configuration files
To store compiled assets
To store language files
Which artisan command is used to create a new model in Laravel?
php artisan make:model
php artisan create:model
php artisan generate:model
php artisan new:model
What is a middleware in Laravel?
A filter for HTTP requests
A type of view
A type of controller
A type of route
Which method in a controller handles a GET request to a specific URL in Laravel?
show()
get()
index()
retrieve()
How do you define a named route in Laravel?
Route::get('/home', 'HomeController@index')->path('home');
Route::get('/home', 'HomeController@index')->url('home');
Route::get('/home', 'HomeController@index')->route('home');
Route::get('/home', 'HomeController@index')->name('home');
What is the purpose of the artisan command in Laravel?
To perform various command-line tasks
To run the web server
To manage user authentication
To compile Blade templates
Which method is used to redirect to another URL in a Laravel controller?
redirect()
return redirect()
return route()
route()
Which of the following is NOT a valid HTTP status code?
200
404
500
700
Which method defines a one-to-one relationship in an Eloquent model?
hasMany()
hasOne()
belongsTo()
belongsToMany()
What is eager loading in Laravel?
Loading related models using a single query.
Loading models without relationships
Loading models with lazy loading
Loading models on demand
What is the purpose of model factories in Laravel?
To create fake data for testing
To define database migrations
To handle model relationships
To manage model validations
Which method is used to perform a soft delete on an Eloquent model?
delete()
destroy()
forceDelete()
softDelete()
How do you restore a soft-deleted model in Laravel?
restore()
revive()
undelete()
revert()
What package is commonly used for debugging Laravel applications in development mode?
Laravel Telescope
Laravel DebugBar
Laravel Cashier
Laravel Mix
Which Blade directive is used to include a view within another view?
@include
@yield
@section
@extends
