Learn Laravel MCQs

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

What is the command to generate a new mail class in Laravel?

1) php artisan make:mail

2) artisan create:mail

3) make:mail

4) create:mail

Answer : Option 1

How do you validate data in a controller in Laravel?

1) validate()

2) validateData()

3) request()->validate()

4) checkValidation()

Answer : Option 3

What is the command to generate a new console command in Laravel?

1) php artisan make:command

2) artisan create:command

3) make:command

4) create:command

Answer : Option 1

How can you retrieve the URL for a named route in Laravel?

1) route("name")

2) url("name")

3) namedRoute("name")

4) routeUrl("name")

Answer : Option 1

What is the command to view the application version in Laravel?

1) php artisan --version

2) php artisan version

3) php artisan app:version

4) php artisan check:version

Answer : Option 1

How do you create a new database migration file in Laravel?

1) php artisan migrate:create

2) php artisan make:migration

3) php artisan migration:create

4) artisan create:migration

Answer : Option 1

What is the purpose of the `config/app.php` file?

1) Store application configuration

2) Store database configuration

3) Store routing configuration

4) Store middleware configuration

Answer : Option 1

How do you define a route with a prefix in Laravel?

1) Route::prefix("prefix")->group()

2) Route::group(prefix: "prefix")

3) Route::withPrefix("prefix")

4) Route::addPrefix("prefix")

Answer : Option 1

What is the command to create a new channel for broadcasting in Laravel?

1) php artisan make:broadcast

2) artisan create:broadcast

3) make:broadcast

4) create:broadcast

Answer : Option 1

How do you define a scheduled command in Laravel?

1) app/Console/Kernel.php

2) app/Schedule.php

3) app/Console/Commands.php

4) app/Schedule/Kernel.php

Answer : Option 1