Laravel Flashcards

Interview Questions

1
Q

What is Laravel

A

Laravel is free open source “PHP framework” based on MVC design pattern.
It is created by Taylor Otwell. Laravel provides expressive and elegant syntax that helps in creating a wonderful web application easily and quickly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are pros and cons of using Laravel Framework?

A

Pros of using Laravel Framework

Laravel framework has in-built lightweight blade template engine to speed up compiling task and create layouts with dynamic content easily.
Hassles code reusability.
Eloquent ORM with PHP active record implementation
Built in command line tool “Artisan” for creating a code skeleton , database structure and build their migration

Cons of using laravel Framework

Development process requires you to work with standards and should have real understanding of programming
Laravel is new framework and composer is not so strong in compare to npm (for node.js), ruby gems and python pip.
Development in laravel is not so fast in compare to ruby on rails.
Laravel is lightweight so it has less inbuilt support in compare to django and rails. But this problem can be solved by integrating third party tools, but for large and very custom websites it may be a tedious task
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain Events in laravel

A

An event is an action or occurrence recognized by a program that may be handled by the program or code. Laravel events provides a simple observer implementation, that allowing you to subscribe and listen for various events/actions that occur in your application.

All Event classes are generally stored in the app/Events directory, while their listeners are stored in app/Listeners of your application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain validations in laravel?

A

In programming validations are a handy way to ensure that your data is always in a clean and expected format before it gets into your database. Laravel provides several different ways to validate your application incoming data. By default Laravel’s base controller class uses a ValidatesRequests trait which provides a convenient method to validate all incoming HTTP requests coming from client.You can also validate data in laravel by creating Form Request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to install laravel via composer

A

composer create-project laravel/laravel your-project-name version

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is PHP artisan. List out some artisan commands ?

A

PHP artisan is the command line interface/tool included with Laravel. It provides a number of helpful commands that can help you while you build your application easily.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List some default packages provided by Laravel 5.6

A
Cashier
    Envoy
    Passport
    Scout
    Socialite
    Horizon
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are named routes in Laravel

A

Named routing is another amazing feature of Laravel framework. Named routes allow referring to routes when generating redirects or Urls more comfortably.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is database migration

A

Migrations are like version control for your database, that’s allow your team to easily modify and share the application’s database schema.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are service providers

A

Service Providers are central place where all laravel application is bootstrapped. Your application as well all Laravel core services are also bootstrapped by service providers.
All service providers extend the Illuminate\Support\ServiceProvider class. Most service providers contain a register and a boot method. Within the register method, you should only bind things into the service container. You should never attempt to register any event listeners, routes, or any other piece of functionality within the register method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain Laravel’s service container

A
One of the most powerful feature of Laravel is its Service Container. It is a powerful tool for resolving class dependencies and performing dependency injection in Laravel.
Dependency injection is a fancy phrase that essentially means class dependencies are “injected” into the class via the constructor or, in some cases, “setter” methods.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is composer

A

Composer is a tool for managing dependency in PHP. It allows you to declare the libraries on which your project depends on and will manage (install/update) them for you.
Laravel utilizes Composer to manage its dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is dependency injection in Laravel

A

In software engineering, dependency injection is a technique whereby one object supplies the dependencies of another object. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it. The service is made part of the client’s state. Passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are Laravel Contracts

A

Laravel’s Contracts are nothing but a set of interfaces that define the core services provided by the Laravel framework.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain Facades in Laravel

A

Laravel Facades provides a static like an interface to classes that are available in the application’s service container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are Laravel eloquent

A

Laravel’s Eloquent ORM is simple Active Record implementation for working with your database. Laravel provide many different ways to interact with your database, Eloquent is most notable of them.

17
Q

How to enable query log in Laravel

A

Use the enableQueryLog method to enable query log in Laravel

18
Q

What is reverse routing in Laravel

A

Laravel reverse routing is generating link’s based on route declarations.

19
Q

What are traits in Laravel

A

PHP Traits are simply a group of methods that you want include within another class. A Trait, like an abstract class cannot be instantiated by itself. Trait are created to reduce the limitations of single inheritance in PHP by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.

20
Q

Does Laravel support caching

A

Yes, Laravel supports popular caching backends like Memcached and Redis.
By default, Laravel is configured to use the file cache driver, which stores the serialized, cached objects in the file system.For large projects, it is recommended to use Memcached or Redis.

21
Q

Explain Laravel’s Middleware

A

As the name suggests, Middleware acts as a middleman between request and response. It is a type of filtering mechanism. For example, Laravel includes a middleware that verifies whether the user of the application is authenticated or not. If the user is authenticated, he will be redirected to the home page otherwise, he will be redirected to the login page.

There are two types of Middleware in Laravel.
Global Middleware: will run on every HTTP request of the application.
Route Middleware: will be assigned to a specific route.

22
Q

What is Lumen

A

Lumen is PHP micro-framework that built on Laravel’s top components.It is created by Taylor Otwell. It is perfect option for building Laravel based micro-services and fast REST API’s. It’s one of the fastest micro-frameworks available.

23
Q

Explain Bundles in Laravel

A

In Laravel, bundles are also called packages. Packages are the primary way to extend the functionality of Laravel. Packages might be anything from a great way to work with dates like Carbon, or an entire BDD testing framework like Behat. In Laravel, you can create your custom packages too.

24
Q

How to use custom table in Laravel Modal

A

You can use custom table in Laravel by overriding protected $table property of Eloquent.

25
Q

List types of relationships available in Laravel Eloquent

A

Below are types of relationships supported by Laravel Eloquent ORM.

    One To One
    One To Many
    One To Many (Inverse)
    Many To Many
    Has Many Through
    Polymorphic Relations
    Many To Many Polymorphic Relations
26
Q

List some Aggregates methods provided by query builder in Laravel

A
count()
    max()
    min()
    avg()
    sum()