Magento 2
Create a Route
Free Preview
app/code/Foo/Bar/etc/frontend/routes.xml
<?xml version="1.0"?>
<!--
We'll place this file in either the "frontend" or "adminhtml" folder, to define
either a frontend or admin route, respectively.

The "urn:magento:framework:App/etc/routes.xsd" file is used to validate this
XML file. We can inspect it at: vendor/magento/framework/App/etc/routes.xsd
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <!-- The "standard" router is used to handle standard Magento requests. -->
    <router id="standard">
        <!--
        The "id" attribute is used as a unique key for this node. It should
        almost always match the value of "frontName" for consistency reasons.
        Its value cannot contain dashes, so underscores are used instead.

        The "frontName" is used to catch incoming requests. This route listens
        for requests being made to: /my-route/*/*
        -->
        <route id="my_route" frontName="my-route">
            <!--
            The "route" node looks for "module" nodes with "name" attributes.
            These are the modules responsible for handling these requests.
            -->
            <module name="Foo_Bar"/>
        </route>
    </router>
</config>
Want to learn more?

Visit M.academy to learn much more about Magento, Laravel, PHP, Javascript, & Docker.

M.academy logo