Interview questions for Laravel Php

1. What do you mean by bundles?

In Laravel, bundles are referred to as packages. These packages are used to increase the functionality of Laravel. A package can have views, configuration, migrations, routes, and tasks.

2. What is Database Migration and how to use this in Laravel?

Database migration is like the version control of the database, which allows the team to modify and share the database schema of the application. Database migrations are paired with the schema builder of Laravel which is used to build the database schema of the application. It is a type of version control for our database. It is allowing us to modify and share the application’s database schema easily. A migration file contains two methods up() and down(). up() is used to add new tables, columns, or indexes database and the down() is used to reverse the operations performed by the up method.

3. What are Laravel’s Contracts?

Laravel’s Contracts are a set of interfaces that define the core services provided by the framework. For example, a Illuminate\Contracts\Queue\Queue contract defines the methods needed for queueing jobs, while the Illuminate\Contracts\Mail\Mailer contract defines the methods needed for sending e-mail.

4. What is Database Migration and how to use this in Laravel?

Database migration is like the version control of the database, which allows the team to modify and share the database schema of the application. Database migrations are paired with the schema builder of Laravel which is used to build the database schema of the application.
It is a type of version control for our database. It is allowing us to modify and share the application’s database schema easily.
A migration file contains two methods up () and down ().
up() is used to add new tables, columns, or indexes database and the down() is used to reverse the operations performed by the up method.

5. What is Auth? How is it used?

Laravel Auth is the process of identifying the user credentials with the database. Laravel managed it’s with the help of sessions which take input parameters like username and password, for user identification. If the settings match then the user is said to be authenticated.
Auth is in-built functionality provided by Laravel; we have to configure.
We can add this functionality with php artisan make: auth
Auth is used to identifying the user credentials with the database.

6. How to remove /public from URL in laravel?

You can do this in various ways. Steps are given below:-
• Copy .htaccess file from public folder and now paste it into your root.
• Now rename server.php file/page to index.php on your root folder.
• Now you can remove /public word from URL and refresh the page. Now it will work.

7. Explain important directories used in a common Laravel application?

Directories used in a common Laravel application are:
• App/: This is a source folder where our application code lives. All controllers, policie and models are inside this folder.
• Config/: Holds the app’s configuration files. These are usually not modified directly but instead, rely on the values set up in the .env (environment) file at the root of the app.
• Database/: Houses the database files, including migrations, seed and test factories.
• Public/: Publicly accessible folder holding compiled assets and of course an index.php file.

8. What do you mean by bundles?

In Laravel, bundles are referred to as packages. These packages are used to increase the functionality of Laravel. A package can have views, configuration, migrations, routes, and tasks.

9. What is Database Migration and how to use this in Laravel?

Database migration is like the version control of the database, which allows the team to modify and share the database schema of the application. Database migrations are paired with the schema builder of Laravel which is used to build the database schema of the application. It is a type of version control for our database. It is allowing us to modify and share the application’s database schema easily. A migration file contains two methods up() and down(). up() is used to add new tables, columns, or indexes database and the down() is used to reverse the operations performed by the up method.

10. What are Laravel’s Contracts?

Laravel’s Contracts are a set of interfaces that define the core services provided by the framework. For example, a Illuminate\Contracts\Queue\Queue contract defines the methods needed for queueing jobs, while the Illuminate\Contracts\Mail\Mailer contract defines the methods needed for sending e-mail.

11. What is Database Migration and how to use this in Laravel?

Database migration is like the version control of the database, which allows the team to modify and share the database schema of the application. Database migrations are paired with the schema builder of Laravel which is used to build the database schema of the application.

It is a type of version control for our database. It is allowing us to modify and share the application’s database schema easily.

A migration file contains two methods up () and down ().

up() is used to add new tables, columns, or indexes database and the down() is used to reverse the operations performed by the up method.

12. What is Auth? How is it used?

Laravel Auth is the process of identifying the user credentials with the database. Laravel managed it’s with the help of sessions which take input parameters like username and password, for user identification. If the settings match then the user is said to be authenticated.

Auth is in-built functionality provided by Laravel; we have to configure.

We can add this functionality with php artisan make: auth

Auth is used to identifying the user credentials with the database.

13. to remove /public from URL in laravel?

You can do this in various ways. Steps are given below:-

  • Copy.htaccess file from public folder and now paste it into your root.
  • Now renamephp file/page to index.php on your root folder.
  • Now you can remove /public word from URL and refresh the page. Now it will work.

14. Explain important directories used in a common Laravel application?

Directories used in a common Laravel application are:

  • App/: This is a source folder where our application code lives. All controllers, policie and models are inside this folder.
  • Config/: Holds the app’s configuration files. These are usually not modified directly but instead, rely on the values set up in the .env (environment) file at the root of the app.
  • Database/: Houses the database files, including migrations, seed and test factories.
  • Public/: Publicly accessible folder holding compiled assets and of course an index.php file.

 15. Define Lumen?

Lumen is a micro-framework. It is a smaller, and faster, version of a building Laravel based services, and REST API’s.

16. Explain PHP artisan?

An artisan is a command-line tool of Laravel. It provides commands that help you to build Laravel application without any hassle.

17. How can you generate URLs?

Laravel has helpers to generate URLs. This is helpful when you build link in your templates and API response.

18. Explain Extending Bindings?

The extend method allows the modification of resolved services. For example, when a service is resolved, you may run additional code to decorate or configure the service. The extend method accepts a Closure, which should return the modified service, as its only argument:

$this->app->extend(Service::class, function($service) {
return new DecoratedService($service);

19. What is the make Method?

  1. A) You may use the make method to resolve a class instance out of the container. The make method accepts the name of the class or interface you wish to resolve:

$api = $this->app->make(‘HelpSpot\API’);

20. Which class is used to handle exceptions?

Laravel exceptions are handled by App\Exceptions\Handler class.

21. Explain the bindings And singletons Properties?

If your service provider registers many simple bindings, you may wish to use the bindings and singletons properties instead of manually registering each container binding. When the service provider is loaded by the framework, it will automatically check for these properties and register their bindings

22. What are common HTTP error codes?

The most common HTTP error codes are:

  • Error 404 – Displays when Page is not found.
  • Error- 401 – Displays when an error is not authorized

23. What is a Controller?

A controller is the “C” in the “MVC” (Model-View-Controller) architecture, which is what Laravel is based on.

24. Explain reverse routing in Laravel.

Reverse routing is a method of generating URL based on symbol or name. It makes your Laravel application flexible.

25. What are Facades?

Facades provide a “static” interface to classes that are available in the application’s service container.

26. Explain traits in Laravel?

Laravel traits are a group of functions that you include within another class. A trait is like an abstract class. You cannot instantiate directly, but its methods can be used in concreate class.

27. Difference between Facades Vs. Dependency Injection?

One of the primary benefits of dependency injection is the ability to swap implementations of the injected class. This is useful during testing since you can inject a mock or stub and assert that various methods were called on the stub.

Typically, it would not be possible to mock or stub a truly static class method. However, since facades use dynamic methods to proxy method calls to objects resolved from the service container, we actually can test facades just as we would test an injected class instance.

Lumen is a micro-framework. It is a smaller, and faster, version of a building Laravel based services, and REST API’s.

28. Explain PHP artisan?

An artisan is a command-line tool of Laravel. It provides commands that help you to build Laravel application without any hassle.

29. How can you generate URLs?

Laravel has helpers to generate URLs. This is helpful when you build link in your templates and API response.

30. Explain Extending Bindings?

The extend method allows the modification of resolved services. For example, when a service is resolved, you may run additional code to decorate or configure the service. The extend method accepts a Closure, which should return the modified service, as its only argument:
$this->app->extend(Service::class, function($service) {
return new DecoratedService($service);

31. What is the make Method?

You may use the make method to resolve a class instance out of the container. The make method accepts the name of the class or interface you wish to resolve:
$api = $this->app->make(‘HelpSpot\API’);

32.  Which class is used to handle exceptions?

Laravel exceptions are handled by App\Exceptions\Handler class.

33. Explain the bindings And singletons Properties?

If your service provider registers many simple bindings, you may wish to use the bindings and singletons properties instead of manually registering each container binding. When the service provider is loaded by the framework, it will automatically check for these properties and register their bindings

34) What are common HTTP error codes?

The most common HTTP error codes are:
• Error 404 – Displays when Page is not found.
• Error- 401 – Displays when an error is not authorized

35. What is a Controller?

A controller is the “C” in the “MVC” (Model-View-Controller) architecture, which is what Laravel is based on.

36. Explain reverse routing in Laravel?

Reverse routing is a method of generating URL based on symbol or name. It makes your Laravel application flexible.

37. What are Facades?

Facades provide a “static” interface to classes that are available in the application’s service container.

38. Explain traits in Laravel?

Laravel traits are a group of functions that you include within another class. A trait is like an abstract class. You cannot instantiate directly, but its methods can be used in concreate class.

39. Difference between Facades Vs. Dependency Injection?

One of the primary benefits of dependency injection is the ability to swap implementations of the injected class. This is useful during testing since you can inject a mock or stub and assert that various methods were called on the stub.
Typically, it would not be possible to mock or stub a truly static class method. However, since facades use dynamic methods to proxy method calls to objects resolved from the service container, we actually can test facades just as we would test an injected class instance.

leave your comment


Your email address will not be published. Required fields are marked *