Magento Module Development Series – Part4- Module – Hello world

In this blog post, we will learn how to start magento module development and basic files required setup a module.

This is a basic hello world module, what will do is simple print “helloworld” on a magento page, using our custom module. As we have seen earlier, Magento modules follows, MVC pattern i.e. Model , View and Controllers. So in our module also we will have to create files following the MVC architecture.

Before starting with the module we need to first decide the name of the module, because after creating a module it’s very difficult to change the name of the module.
Module name usually comprises of 2 parts <CompanyName>_<ModuleName> or it’s also called <Namespace>_<Module>. In our case I will take the name of module as Excellence_Test.
First step is to create the folders and files for our module.
First file we will create is Excellence_Test.xml file in location app/etc/modules/

<?xml version="1.0"?>
        <Excellence_Test>   <!-- Name of Module --> 
            <active>true</active>  <!-- This says if the module is active or not -->
            <codePool>local</codePool> <!-- This says the location of the module i.e inside the local folder. It can also be community folder. -->

This is a very important file, which tells magento about our module. Based on this file only, magento reads our module files. If in some case, you would want to disable the module, you can simple rename this file to some other name.
Next go the folder app/code/local/ and then create folder structure as shown here Magento Module Folder Structure
Next we create the configuration file of the module: config.xml inside folder Excellence/Test/etc. So etc/config.xml is created

<?xml version="1.0"?>
			<version>0.1.0</version>    <!-- Version of module -->
					<frontName>test</frontName>  <!-- This is the URL
 of the module. i.e will be the url of your module. -->
				<class>Excellence_Test_Block</class>  <!-- Path of the
 Block Folder, where all php files are located related to view -->
<!-- Path of Helper Files -->

Next, we will create the Controller file. Controller files are used to manage between view and models. Controllers files are the first file to get executed when open a URL. Will explain URL and Controller relationship in detail later.
Now lets create a file called IndexController.php.

class Excellence_Test_IndexController extends Mage_Core_Controller_Front_Action
    public function indexAction()
		echo "Hello World";

Here are few important things to note:

  1. First is class name i.e Excellence_Test_IndexController
    In magento, class name depends on the folder location of the file.
    So for example the class Mage_Core_Controller_Front_Action, exists at location Mage/Core/Controller/Front/Action.php
  2. All controller file must extend Mage_Core_Controller_Front_Action to work properly

Ok, now to test if the module work properly open the url this should display Hello World on the screen.


  • When creating controller files or block file, etc remember to be careful about case sensitivity of file names. Especially, when you upload your module to linux server the module may stop working, if file cases and class name have not been put in carefully.
  • All class names should be case-sensitive as well. Basically, based on the class name, magento includes that file. So, if class name is not correct, the file is not found by magento.
  • If you’re module beginner, try to keep the module name CamelCased
  • . If your choose module names like Excellence_TestReport this might create a problem. As you can see “TestReport” has two capital letter, so this sometimes creates the problem in linux server.

  • It’s general good practice to keep all public functions in magento as CamelCased