Quantcast
Channel: Magento 2 – DCKAP
Viewing all articles
Browse latest Browse all 135

Request Flow in Magento 2

$
0
0

There is a lot of buzz around Magento 2 and about its new features that promises to improve user experience and performance.

One of the key changes made is in the request flow (i.e.) the path taken by the system from the time an user clicks a page to the time it is served as a page in the front end.

In Magento 1, both the front end and back end configuration files will be loaded for each request. But in Magento 2, only the related configuration files of that area will be loaded.

E.g. in Magento 1.x, if you click “Registration” Page in the front end, it loads the entire configuration files including the front end and the back end. But in Magento 2, it will load only the configuration file related to the front end.

This greatly improves the performance (i.e.) request-response time of the website thus enhancing the user experience.

In this blog, we will discuss the request flow in Magento 2.

Step 1 :

Request hits index.php in root folder of Magento 2.

Step 1a

 

 

 

 

 

 

 

Step 2 :

index.php calls static create() method of bootstrap class to create objectmanagerfactory and bootstrap objects.

Step 2a

Step 2b

 

Step 3:

index.php calls createApplication() method of bootstrap object which in turn will initiate ObjectManager using objectManagerFactory. Then, application instance gets created using objectManager and returned to index.php.

Step 3a

 

 

 

 

 

 

 

Step 3b

 

 

Step 3c

 

 

 

 

 

 

 

Step 3d

 

Step 4:

index.php calls run() method of bootstrap object to run the application, which in turn will call launch() method of application object.

Step 4a

 

Step 4b

 

Step 4c

 

 

 

 

 

 

 

Step 5

HTTP Application instance does initial routing. It takes first part of the URL to find out which area should be loaded (admin/frontend).

When the area is defined, configuration for that area is loaded (unlike Magento 1 where all configuration was loaded).

Then application object calls Magento\Framework\App\FrontControllerInterface::dispatch of requested area.

Step 5a

 

Step 5b

 

 

 

 

 

 

 

Step 6:

Front Controller does routing same as in Magento 1. All routers are iterated to match request. The router that matches the request returns instance of ActionController. When FrontController gets instance of action controller it calls dispatch method on it. This process is more efficient because only routers of one area are used (admin router is not used in frontend).

Step 6a

 

Step 7:

Action controller performs its task and returns instance of some implementation of ResultInterface.

Step 7a

 

 

 

 

 

 

Step 7b

 

 

 

 

 

Step 8:

FrontController just returns ResultInterface to Application Instance that renders the response.

Step 8a

 

There is much more to Magento 2 than request flow. If you want dig deep, please find below a few useful links.

Reference

http://magento.stackexchange.com/questions/72923/request-flow-of-magento-2

Magento 2 Useful Links
Magento 2 Demo Store – Feel Free to Login and Play Around

DCKAP has created a Magento 2 demo store. Developers and Merchants are encouraged to login and play around to get a first hand ‘look and feel’ of Magento 2.

Login Details

Store URL – http://magento2demo.dckap.com/
Admin URL – http://magento2demo.dckap.com/m2admin/
Username-demo
Password-demo1234

PLANNING FOR A MAGENTO UPGRADE ?
Magento upgrades can be trickier than you expect. Leave it to the experts and we will take care of it.

This post Request Flow in Magento 2 appeared first on


Viewing all articles
Browse latest Browse all 135

Trending Articles