Learn Laravel MCQs

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

What is the purpose of Laravel Sanctum?

1) User Authentication

2) API Token Management

3) Event Broadcasting

4) Middleware Registration

Answer : Option 2

Which of the following is an example of a Laravel Blade comment?

1) {{-- This is a comment --}}

2) <!-- This is a comment -->

3) {# This is a comment #}

4) /* This is a comment */

Answer : Option 1

What is the default cache driver in Laravel?

1) Redis

2) Memcached

3) File

4) Database

Answer : Option 3

How do you define a custom helper function in Laravel?

1) Create a file in the app/Helpers directory

2) Add the function to the routes file

3) Create a helper service

4) Write it in the Middleware

Answer : Option 1

What is the default method for validating forms in Laravel?

1) Form::validate()

2) request()->validate()

3) Input::validate()

4) Validator::run()

Answer : Option 2

Which command is used to start Laravel Scheduler?

1) php artisan schedule:run

2) php artisan scheduler:start

3) php artisan start:scheduler

4) php artisan make:scheduler

Answer : Option 1

How do you retrieve the current route name in Laravel?

1) route()->currentName()

2) request()->route()->getName()

3) Route::name()

4) request()->currentRoute()

Answer : Option 2

What is Laravel Spark used for?

1) Subscription billing management

2) Event broadcasting

3) Task scheduling

4) API Authentication

Answer : Option 1

How do you define a foreign key in Laravel migrations?

1) foreign()

2) references()

3) foreignKey()

4) ref()

Answer : Option 1

Which Artisan command is used to optimize Laravel?

1) php artisan optimize

2) php artisan clear:optimize

3) php artisan optimize:all

4) php artisan cache:optimize

Answer : Option 1