The controller

At its core, Magento is a Model-View-Controller (MVC) framework, so in order to make our new route functional, we have to create a new controller that will respond to this specific route. To do this, perform the following steps:

  1. Navigate to the extension root directory.
  2. Create a new folder called controllers.
  3. Inside the controllers folder create a file called IndexController.php.
  4. Copy the following code:

    The file location is app/code/local/Mdg/Hello/controllers/IndexController.php.

    <?php 
    class Mdg_Hello_IndexController extends Mage_Core_Controller_Front_Action
    {
         public function indexAction()
      {
         echo 'Hello World this is the default action';
         }
    }

Get Magento PHP Developer's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.