According to DevDocs,
In web applications, such as Adobe Commerce and Magento Open Source, routing is the act of providing data from a URL request to the appropriate class for processing.
Adobe Commerce and Magento Open Source routing uses the following flow:
![](https://jigarkarangiya.com/wp-content/uploads/2024/04/image-6-1024x56.png)
Router class
The Router class matches a request to an action class that processes the request.
The Standard Router (A.K.A the base router) sets module frontName
, Controller Action names, Controller Module & Route Name if found. It processes all standard Magento URLs.
The frontName
attribute value becomes the part of our URL structure. Simply put, the URL formula for hitting the C.R.U.D action is formatted like:
![](https://jigarkarangiya.com/wp-content/uploads/2024/04/image-7.png)
Where:
<store-url>
– specifies the base URL for the application instance<store-code>
– specifies the store context<front-name>
– specifies thefrontName
of the FrontController to use (for example, [routesxml])<controller-name>
– specifies the name of the controller<action-name>
– specifies the action class to execute on the controller class
The standard router parses this URL format and matches it to the correct controller and action.
The id
attribute is the naming convention for Layout Handle XML and is formatted:
{route-id}{controller-name}{action-name}.xml
When configuring a custom routes.xml, it’s easier to keep the id and frontName the same value.
The following tables show the core routers that come with Magento 2:
frontend
area routers:
Name | Sort Order | Description |
robots | 10 | Matches request to the robots.txt file |
urlrewrite | 20 | Matches requests with URL defined in the database |
standard | 30 | The standard router |
cms | 60 | Matches requests for CMS pages |
default | 100 | The default router |
adminhtml area routers:
Name | Sort Order | Description |
admin | 10 | Matches requests in the Admin area |
default | 100 | The default router for the Admin area |
Source : https://developer.adobe.com/commerce/php/development/components/routing/
I hope this article helped you to find what you were looking for.
Bookmark it for your future reference. Do comment below if you have any other questions on that.
Do share this article with your team.
You may also like,
Which refund types are available, and how are they used?
Demonstrate ability to use and customize Categories in Magento 2
Happy Reading & Best of luck for the exam 👍