Learn Laravel MCQs

Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.

What is the default cache driver in Laravel?

1) file

2) database

3) array

4) redis

Answer : Option 1

How can you perform a database query in Laravel?

1) DB::table()

2) DB::query()

3) DB::execute()

4) DB::select()

Answer : Option 1

Which command is used to generate a new event in Laravel?

1) php artisan make:event

2) php artisan create:event

3) make:event

4) artisan make:event

Answer : Option 1

How do you define a many-to-many relationship in Eloquent?

1) belongsToMany()

2) hasMany()

3) hasOne()

4) manyToMany()

Answer : Option 1

What is the purpose of the `config` folder in Laravel?

1) Application configuration

2) Route configuration

3) View configuration

4) Session configuration

Answer : Option 1

Which class is used to handle HTTP requests in Laravel?

1) Request

2) Http

3) Response

4) Input

Answer : Option 1

How do you create a new request class in Laravel?

1) php artisan make:request

2) php artisan new:request

3) make:request

4) artisan create:request

Answer : Option 1

What does `dd()` function do in Laravel?

1) Dump and die

2) Delete data

3) Display data

4) Debug data

Answer : Option 1

What is Laravel Passport used for?

1) API authentication

2) Web authentication

3) Database migrations

4) Email verification

Answer : Option 1

Which of the following is a command to generate a new resource controller?

1) php artisan make:controller --resource

2) php artisan new:controller --resource

3) make:controller --resource

4) artisan create:controller --resource

Answer : Option 1