Learn Laravel MCQs

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

What command generates a controller in Laravel?

1) php artisan make:controller

2) php artisan generate:controller

3) php make controller

4) php artisan build:controller

Answer : Option 1

Which of the following is used to define database tables in Laravel?

1) Routes

2) Migrations

3) Models

4) Controllers

Answer : Option 2

Which of these is the correct syntax to access configuration in Laravel?

1) config('app.name')

2) getConfig('app.name')

3) app_config('app.name')

4) setting('app.name')

Answer : Option 1

What does Eloquent ORM provide?

1) Active Record Implementation

2) Data Seeding

3) SQL Injection Protection

4) Automatic Controller Generation

Answer : Option 1

Which of the following is a Laravel Middleware?

1) CSRF Protection

2) Password Hashing

3) Routing

4) Session Management

Answer : Option 1

Which file is used to register service providers in Laravel?

1) app.php

2) services.php

3) web.php

4) config.php

Answer : Option 1

Which Artisan command creates a migration?

1) php artisan make:migration

2) php artisan create:migration

3) php artisan db:migrate

4) php artisan migrate:make

Answer : Option 1

What is the purpose of the `.env` file in Laravel?

1) Setting environment variables

2) Routing configuration

3) Database migrations

4) Service provider registration

Answer : Option 1

Which function is used to retrieve old input in forms in Laravel?

1) old()

2) previous()

3) oldInput()

4) getOld()

Answer : Option 1

Which of the following is used to handle errors in Laravel?

1) Exception Handler

2) Error Catcher

3) Error Tracker

4) Debugger

Answer : Option 1