Skip to content

Create Magento 2 Module (Controller) Part II

here step how to working with controller, i will create 2 controllers file, my objective is, to run following url

http://127.0.0.1/magento21/index.php/hellomagentoworld/index/index   and
http://127.0.0.1/magento21/index.php/hellomagentoworld/index/test

  1. create file app\code\Ansyori\HelloWorld\etc\frontend\routes.xml
  2. next, create file app\code\Ansyori\HelloWorld\Controller\Index\Index.php
  3. and app\code\Ansyori\HelloWorld\Controller\Index\Test.php
  4. dont forget, clear magento cache!
  5. then try open both URLs on your browser :
  6. http://127.0.0.1/magento21/index.php/hellomagentoworld/index/index
    http://127.0.0.1/magento21/index.php/hellomagentoworld/index/test

 

Share

Comments are closed.