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
<?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>
2. At [MODULE] create /Controller/Version folders and Index.php in the Version folder
app/code/ScandiPWA/Version/Controller/Version/Index.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');
}
}
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
Copy link