# STEP-2 - Create Magento 2 Frontend Route and Basic Controller

1. At **\[MODULE]/etc** folder create **frontend** folder and **routes.xml** file in it

{% code title="app/code/ScandiPWA/Version/etc/frontend/routes.xml" %}

```markup
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
   <router id="standard">
       <route id="scandipwa"  frontName="scandipwa" >
           <module name="ScandiPWA_Version"/>
       </route>
   </router>
</config>
```

{% endcode %}

2\. At **\[MODULE]** create **/Controller/Version** folders and I**ndex.php** in the **Version** folder

{% code title="app/code/ScandiPWA/Version/Controller/Version/Index.php" %}

```php
<?php

namespace ScandiPWA\Version\Controller\Version;

use Magento\Framework\App\Action\Action;

class Index extends Action
{
   /**
    * @return void
    */
   public function execute()
   {
       echo('Version 5.0.6');
   }
}
```

{% endcode %}

4\. Run and `set:up`  and `c:f`, switch to **Luma** theme, if you will navigate to [**http://localhost/scandipwa/version**](https://localhost/scandipwa/version) you should see the output, however, if you will switch back to **ScandiPWA** theme you going to see 404 Page.

\
**Useful Materials**\
[Magento 2 Creating a New Page](https://devdocs.magento.com/videos/fundamentals/create-a-new-page/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.scandipwa.com/tutorials/accessing-magento-2-controllers/step-2-create-magento-2-frontend-route-and-basic-controller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
