Laravel Interview questions

Laravel is created by the Taylor Otwell which is a free open source PHP web framework specially designed for the development of the web applications ensuring the MVC (model–view–controller) architectural pattern. It is all based on the Symfony. There are more futures associated with the Laravel like modular packaging system with a dedicated dependency manager, utilities that aid in application deployment and maintenance and many more. In addition, there are many different ways of accessing relational databases and its orientation toward syntactic sugar. Moreover, GitHub is used to host the source code of Laravel and it is licensed under the terms of MIT license. So, if you want to know more about Laravel, then check out our Laravel interview questions which are described below. You can crack any interviews by reading our top interview questions.

  • What are pros and cons of using Laravel Framework?

    Posted By: Bharathi

    Pros of Laravel

    1. It uses Blade template engine that helps in speed up compilation tasks and writing cleaner code.
    2. Bundled modularity forces code reusability.
    3. Easy to understand Eloquent ORM.
    4. Outstanding Command Line Interface Artisan.
    5. Clean, clear easily understandable documentation.

    Cons of Laravel

    1. Quite slow because of loading multiple vendors.
    2. Amature developers face some difficulties in staring, but once they are familiar it will be fun to code in Laravel.
    3. Community support is not as wide as a comparison to other frameworks.
    4. Upgrading framework is a headache.

  • What is Laravel service container?

    Posted By: Addison

    Service Container in Laravel is a Dependency Injection Container and a Registry for the application. It is one of the most powerful tool for managing class dependencies and performing dependency injection.

  • How To Use Delete Query In Laravel ?

    Posted By: Titus


    is the simplest way to delete a record in Laravel.

  • How To Use Update Query In Laravel ?

    Posted By: Edie

    Updating a record in Laravel using Eloquent.


  • What is Laravel Dusk?

    Posted By: Gabe

    Laravel Dusk is browser automation and testing tool introduced in Laravel 5.4. It uses ChromeDriver to perform browser automation testing.

  • What is Laravel Echo?

    Posted By: Firman

    Laravel Echo is a tool that makes it easy for you to bring the power of WebSockets to your Laravel applications. It simplifies some of the more common—and more complex—aspects of building complex WebSockets interactions.

    Echo comes in two parts: a series of improvements to Laravel's Event broadcasting system, and a new JavaScript package.


  • What is Laravel Homestead ?

    Posted By: Robin

    Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine.

  • What is Tagging?

    Posted By: Esta

    Tagging is a package in Laravel that allow you to tag your content like pages/ post to a keyword.

  • What is dependency injection in Laravel ?

    Posted By: Leander

    Dependency injection or (D.I) is a technique in software Engineering whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service). Injection is the passing of dependency to a dependent object (a client) that would use it.

    Basically, You can found 3 types of dependency injection:

    • Constructor injection
    • Setter injection
    • Interface injection

  • What are named routes in Laravel?

    Posted By: Vernie

    Named routing is another amazing feature of the Laravel framework. Named routes allow referring to routes when generating redirects or URLs more comfortably. You can specify named routes by chaining the name method onto the route definition:


    Route::get('user/profile', function () {

    You can specify route names for controller actions:

    Route::get('user/profile', 'UserController@showProfile')->name('profile');

    Once you have assigned a name to your routes, you may use the route's name when generating URLs or redirects via the global route function:

    // Generating URLs...
    $url = route('profile');
    // Generating Redirects...
    return redirect()->route('profile');


  • What are Laravel eloquent?

    Posted By: Hershel

    Eloquent is an ORM in Laravel that implements active record pattern and is used to interact with relational databases.

  • What is Lumen?

    Posted By: Orla

    Lumen is micro-framework by Laravel. It is developed by the creator of Laravel Taylor Otwell for creating smart and blazing fast API’s. Lumen is built on top components of Laravel. As Lumen is a micro-framework not a complete web framework like Laravel and used for creating API’s only, so most of the components as HTTP sessions, cookies, and templating are excluded from Lumen and only features like routing, logging, caching, queues, validation, error handling, database abstraction, controllers, middleware, dependency injection, Blade templating, command scheduler, the service container, and the Eloquent ORM are kept.

  • What is a Facade?

    Posted By: Thad

    In Programming, Facade is a software design pattern which is often used in object-oriented programming. Laravel facade is a class which provides a static-like interface to services inside the container.

  • How To Use Delete Statement In Laravel?

    Posted By: Loren

    Use delete statement in Laravel:

    In Query Builder Way:

    \DB::table('users')->delete($id); // delete with id
    \DB::table('users')->where('name', $name)->delete(); \\ delete with where condition

    In Eloquent Way:

     User::find($id)->delete() // delete with id
     User::where(['name'=>$name])->delete();  \\ delete with where condition

  • Difference between Contracts and Facades?

    Posted By: Freeman

    Contracts are an interface, while Facades are not an interface. it is a class. 

    Contracts are a set of interfaces that define the core services provided by the framework, while Facades provide a static interface to classes that are available in the application's service container.


  • What is an Observer in Laravel?

    Posted By: Tommy

    An observer attaches to an Eloquent Model for Laravel.

    This observer can listen to many different events that happen on the model such as: creating, created, saving, saved, deleting, deleted and many more... All of which you can find here:

    The observer listens for these events and fires whenever said action is triggered, letting you preform pre or post procedure statements whenever an action is taken.

     For instance, if you have a user registration page, and every time you create a user, you want to ensure that the password is hashed... You can hook into the User "creating" event.

     public function creating(User $user) {
      $user->password = bcrypt($user->password);


     This will ensure that every time a user is created with a password, that password is automatically hashed.

     In order to register the Observer, you should place it in either the boot() section of your AppServiceProvider or your own custom provider. Note: if you use a custom provider, be sure to register it in config/app.php

    You will need the model and the observer. IE:


    boot() {
       User::observe(new UserObserver);

    // That's it...


    Now any events that the User model fires will be performed by the User Observer if you have identified any in the observer.

  • How to get current Url in Laravel ?

    Posted By: Andreasdli

    In Laravel 5.5 or above you can use url()->current(); to get current URL without query string and  url()->full(); with the query string.

  • How To Use Select Query In Laravel?

    Posted By: Doctor


    This will create a collection that only contains the 'name' property of ever user...


    This will select name and username from users

  • Which template engine Laravel use ?

    Posted By: Webki Mad

    Laravel uses Blade template Engine.

  • How to use custom table in Laravel Model ?

    Posted By: Martha

    protected $table = 'custom_table_name';

    Attach this to your CustomModel.php



  • What are Closures in laravel ?

    Posted By: Oscar

    A Closure is an anonymous function that often used as callback methods and can be used as a parameter in a function.

    Example of Laravel Closure

    User::with('profile', function ($builder) {
    	// Get me all collapsed comments
    	return $builder->whereCollapsed(true);

  • How to get Logged in user info in Laravel ?

    Posted By: Cora

  • Does laravel support php 7?

    Posted By: Najim Mulla

    Yes, Laravel supports PHP 7.

  • What is Laravel Elixir ?

    Posted By: kristen gorge

    Laravel Elixir provides a clean, fluent API for defining basic Gulp tasks for your Laravel application. Elixir supports several common CSS and JavaScript pre-processors, and even testing tools. Using method chaining, Elixir allows you to fluently define your asset pipeline.

    Laravel Elixir Example

    elixir(function(mix) {

  • What is the latest version of laravel?

    Posted By: Franklin

  • How can you display HTML with Blade in laravel

    Posted By: Bessie

  • How to install laravel via composer ?Syntax

    Posted By: Irwin

  • What are Cookies ? How to get , set , distroy cookies in Laravel ?

    Posted By: Clifton

  • How can you Exclude URIs From CSRF Protection in Laravel ?

    Posted By: Cecil

  • What getFacadeAccessor method does

    Posted By: Dell

Laravel vs Lumen



Laravel has a config: cache and route: cache

It does not possess these caches.

It possesses web routes with sessions and API stateless routes

It possesses only stateless routes.

It has a powerful template system

Lumen does not this type of feature

It has poor performance and unsatisfactory speed

Lumen has better performance and better speed than Laravel

Laravel has Symfony.

Lumen does not possess Symfony.

Laravel vs CodeIgniter



It follows the object-oriented method

It follows the relational object-oriented

It is for those who need an elegant and modest kind of toolkit

It is for those who use a simple tool kit

It is object-oriented event-driven functional

It is component driven

It supports explicit routing

It supports explicit and implicit routing

It supports built in the modular feature

It does not support built in the modular feature

It supports HTTP routes

It does not support the HTTP route sufficiently.

Advantages of Laravel

1. New features of PHP can be used

The biggest advantage of the Laravel framework over the others is that it utilizes all the new feature of the PHP. Most of the other frameworks are unable to do it. By using the Laravel 5, you are able to use many new features that are provided by PHP like Interfaces, overloading, Shorter array syntax, Namespaces, Anonymous functions.

2. Great documentation

It is believed that Laravel is develop-friendly due to documentation. All the version of the Laravel is discharged with the proper documentation in which you are able to find good and detailed explanations of classes, coding style, methods.  

3. Integration with mail services

It is very compulsory for web applications to stay in touch with the users and inform them about the new deals and offers. The framework is equipped with API rather than the SwiftMailer library. It also provides the drivers SMTP, Mailgun, SparkPost, Mandrill, PHP’s “mail” function, Amazon SES, and “send email” which helps you in sending the emails through the local services or cloud-based.

4. Supports popular cache backends

One of the more adventitious features is that it supports Memcached and Redis out-of-the-box.

5. Artisan

It is very difficult to do the repetitive programming tasks which are heavily time-consuming. Artisan is the command-line tool which helps in creating the skeleton code and runs the database system strongly.

6. Packages and resource availability

You can take advantages of npm packages and bower packages by connecting the framework with elixir and Gulp. It is very beneficially in resource and asset revisioning. Moreover, this combination with the composer will sort out dependencies and therefore it is the most stable source of the package in the PHP world.

7. A reduced product development cycle

As the integrations are faster it is possible to reduce the product development cycle. Also, you are provided with huge community support and have the assistance of Laracasts.

8. IoC Container

IoC is referred to as the inversion of Control. It is used for generating new objects without bootstrap any external libraries. Simply put, you are able to access these objects from where you are coding, you don't need to deal with inflexible monolithic structures.

9. Reverse Routing

It is also the most beautiful feature of Laravel. In this, you are able to create links to named routes. It is very easy for the users to create the links, just simply use the route's name, and the framework will automatically insert the correct URL. If the user changes the route, the change will occur everywhere.

10. Active Record Implementation

This is one of the most useful features in the framework in which it gives an easy and very helpful ActiveRecord implementation for running with your database. Put differently, it intends that the models you build in the MVC will have a corresponding table in the database.

Disadvantages of Laravel Framework

1. The Composer is not strong enough

As Laravel is a new framework, therefore it is difficult for developers to deal with it. Also, the composer of Laravel is not strong enough in comparison with Ruby gems, npm (node.js), pip (for python), etc.

2. Lack of continuation between versions

No transition from Laravel 4 to 5 has seemed. It could break the application if you try to update the code.

3. Quality is mixed at times

There are some components in the framework which are not well-designed.

For instance, sometimes dependency injection becomes needlessly complex. You have to learn a lot before you start to create applications.

Therefore, it is not suitable for amateur developers.

4. Some upgrades might be problematic

It is not only a Laravel problem but also PHP frameworks that show some troubles when the version is upgraded. So, the user has to take care of the precautions before updating the version.

5. Development

If we check the development of other frameworks, we found out that their development is quite faster in contrast with Laravel.