Creating a controller
In your Magento root, create the following folders: We will add an extra page that we can use for several purposes.
Getting ready
We build further on the Packt_HelloWorld
module that we created in the previous recipe. Ensure that you have this module in your Magento instance. Also, ensure that the full page cache is disabled when you are developing. You can disable this in the backend by navigating to System | Cache Management.
How to do it...
The following steps show how to add extra pages using controllers and controller actions:
Create the following folders:
app/code/Packt/HelloWorld/etc/frontend
app/code/Packt/HelloWorld/Controller
app/code/Packt/HelloWorld/Controller/Index
In the
app/code/Packt/HelloWorld/etc/frontend
folder, create aroutes.xml
file with the following content:<?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...