Top 91 Laravel Interview Questions & Answers


Following are frequently asked Laravel and PHP related interview questions for freshers as well as experienced candidates to get the right job.
1) What is Laravel?
Laravel is an open-source widely used PHP framework. The platform was intended for the development of web application by using MVC architectural pattern. Laravel is released under the MIT license.
Therefore, its source code is hosted on GitHub. It is a reliable PHP framework as it follows expressive and accurate language rules.
2) Define composer.
It is an application-level package manager for PHP. It provides a standard format for managing PHP software dependencies and libraries.
3) What is HTTP middleware?
HTTP middleware is a technique for filtering HTTP requests. Laravel includes a middleware that checks whether application user is authenticated or not.
4) Name aggregates methods of query builder.
Aggregates methods of query builder are: 1) max(), 2) min(), 3) sum(), 4) avg(), and 5) count().
5) What is a Route?
A route is basically an endpoint specified by a URI (Uniform Resource Identifier). It acts as a pointer in Laravel application.
Most commonly, a route simply points to a method on a controller and also dictates which HTTP methods are able to hit that URI.
6) Why use Route?
Routes are stored inside files under the /routes folder inside the project's root directory. By default, there are a few different files corresponding to the different "sides" of the application ("sides" comes from the hexagonal architecture methodology).
7) 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 a Controller?
A controller is the "C" in the "MVC" (Model-View-Controller) architecture, which is what Laravel is based on.
10) Explain reverse routing in Laravel.
Reverse routing is a method of generating URL based on symbol or name. It makes your Laravel application flexible.
12) 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.
13) Explain the concept of contracts in Laravel.
They are set of interfaces of Laravel framework. These contracts provide core services. Contracts defined in Laravel include corresponding implementation of framework.
14) How will you register service providers?
You can register service providers in the config/app.php configuration file that contains an array where you can mention the service provider class name.
15) Where will you define Laravel's Facades?
All facades of Laravel have defined in Illuminate\Support\Facades namespace.
16) State the difference between get and post method.
Get method allows you to send a limited amount of data in the header. Post allows you to send a large amount of data in the body.
17) List default packages of Laravel 5.6.
Default packages of Laravel 5.6 are: 1) Envoy, 2) Passport, 3) Socialite, 4) Cashier, 5) Horizon, and 6) Scout.
18) What is service container in Laravel?
Service container is a tool used for performing dependency injection in Laravel.
19) How can you enable query log in Laravel?
You can use enableQueryLog method to enable query log in Laravel.
20) Explain the concept of events in Laravel.
An event is an occurrence or action that help you to subscribe and listen for events that occur in Laravel application. Some of the events are fired automatically by Laravel when any activity occurs.

Thanks.

Post a Comment

0 Comments