STEP-2 - Create Magento 2 Frontend Route and Basic Controller
  1. 1.
    At [MODULE]/etc folder create frontend folder and routes.xml file in it
app/code/ScandiPWA/Version/etc/frontend/routes.xml
1
<?xml version="1.0" ?>
2
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
3
<router id="standard">
4
<route id="scandipwa" frontName="scandipwa" >
5
<module name="ScandiPWA_Version"/>
6
</route>
7
</router>
8
</config>
Copied!
2. At [MODULE] create /Controller/Version folders and Index.php in the Version folder
app/code/ScandiPWA/Version/Controller/Version/Index.php
1
<?php
2
3
namespace ScandiPWA\Version\Controller\Version;
4
5
use Magento\Framework\App\Action\Action;
6
7
class Index extends Action
8
{
9
/**
10
* @return void
11
*/
12
public function execute()
13
{
14
echo('Version 5.0.6');
15
}
16
}
Copied!
4. Run and set:up and c:f, switch to Luma theme, if you will navigate to http://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
Last modified 1mo ago
Copy link