Magento 2 : What is Router Id = admin & standard ?

Standard Routing in Magento 2

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:

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:

Where:

  • <store-url> – specifies the base URL for the application instance
  • <store-code> – specifies the store context
  • <front-name> – specifies the frontName 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

Magento Exam Information

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:

NameSort OrderDescription
robots10Matches request to the robots.txt file
urlrewrite20Matches requests with URL defined in the database
standard30The standard router
cms60Matches requests for CMS pages
default100The default router

adminhtml area routers:

NameSort OrderDescription
admin10Matches requests in the Admin area
default100The 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 πŸ‘

Leave a Reply

Your email address will not be published. Required fields are marked *