Get Free Audit

Request Routing in Magento 2

Jun 8, 2017

1420 Dmitry Urbanovich

Request Routing in Magento 2

In the article, we’re going to compare routing in Magento 1 and Magento 2. Actually, there’s an article containing routing description in Magento 1, so in case you’d like to have a closer look at routing in Magento 1, read our blog.

Route determination starts from searching for current route defined in the system. The process starts here:

/vendor/magento/framework/App/FrontController.php


In the method dispatch() as well as in Magento 1 file app/code/core/Mage/Core/Controller/Varien/Front.php there are some matches:

  • Checking is a request by dispatcher ($request->isDispatched());
  • Searching for matches ($router->match($request)).

In comparison with Magento 1, there are only two routings determined in Magento 2:

  • /vendor/magento/framework/App/Router/Base.php;
  • /vendor/magento/framework/App/Router/DefaultRouter.php.

The same as in Magento 1, after 100 iterations if a router is not found, there will be a message displayed. Here we can find attributes of Magento 1:


The main steps of routing process are the same as in Magento 1:

  • Determining module
  • Determining controller
  • Action for detection
  • Data for current request detection

Router initialization in Magento 2 differs from Magento 1:


Initialization occurs when searching for an appropriate router:


Further routing process resembles Magento 1:

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


The first three elements are considered as main. They define a module, controller, and action for a current request.

Then module is determined from its moduleFrontName:


Then a controller and action for a current request are determined:


Besides, it is checked whether the connection is safe if there is a controller file, as well as previous realization, is stored:


It implies that route is processed. Module, controller, and action are determined. Moreover, an action for a current request is being processed.


Control element returns for performing action:


Where for a current request output is determined.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *