How to Create Custom Router in Magento 2

Apr 17, 20181598Gennadiy Haritonov
How to Create Custom Router in Magento 2

We are going on with our Magento 2 tutorials and today we are reviewing the process of custom router creation in Magento 2. This is the second article out of the series devoted to Magento 2 how-to’s, be sure to check out last week’s Part 1, were we explored Controllers, Routers and Responses in Magento 2.

So, how do you create Custom routers in Magento2?

Custom Router

To create a router first you need to add it to the \Magento\Framework\App\RouterList, which is transferred to the Front Controller and contains all the available routers in the right order. To do this, we use the di.xml file in our module.

After that we need to create a CustomRouter class.

And finally we need to create a routes.xml file.

That was a brief overview of creating Custom Router in Magento 2. As I mentioned before, this is the 2nd part of the 3-part series devoted to Magento 2 tutorials. Part 3 is about to be published soon.

1 comment

Post a new comment

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