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
  • Michael

    You should specify that IndexController.php goes in the Test/controllers directory.  You sort of imply that the path should be Excellence/Test/IndexController.php by giving the example of the path for Mage_Core_Controller_Front_Action being Mage/Core/Controller/Front/Action.php.

    • Manish Prakash

      Sorry, couldn’t understand what you mean.

  • DrZ

    I’m getting this output:ForbiddenYou do not have permission to access this document. 

    Any ideas?

    • Manish Prakash

      Where do you see this

  • hi..i am always getting error 404 for any module i am creating…is there a solution?
    can anyone help please?

  • Rajan


  • gaurav

    i have downloaded latest version of magento :

    file structure there is

    magento/app/code/(core& community)

    not as magento/app/code/local

    • U must create local folder, and in local folder U must create controllers, models, etc, sql, Block and all the rest of them

  • You may need to flush your cache. config.xml is one of the files cached. I just turned them all off while developing.

  • Nice tutorial. Couple of minor things that will bite you.

    If you copy the code for index controller out of the post, you need to add at the end.

    I couldn’t get magento/test to work, but magento/index.php/test does work. This may have to do with my installed configuration.

  • Nicolas

    It did exactly all you did but It does not work. Please Help. The URL I end up on a page “NOT FOUND”. When I use I end up on the wamp server page but no “Hello world”. Please Help

  • Ravi Patel

    I tried to create hello world module. i have follow all the above all steps. but all time i have get 404 Not Found occured

  • Sandip Shah

    OK. I tried everything and it did not work. I had to make two changes:

    put the IndexController.php file in Excellence/Test/ folder.

    And the IndexController.php file is missing <?php at the top

    After making these two changes, both the urls work

    Thanks for the Tutorial series.


    • Manish Prakash

      You need to place the IndexController.php inside the “controllers” folder.
      Then it will work 🙂

  • Vetrivel

    Hi, I tried to follow above ways, it works perfectly….

  • Yogesh Patel

    Hi, i also have the same problem but when i tried by adding “index.php” in url, it works perfectly. thanks

  • Bhadresh siddhapara

    It’s work perfectly in magento 1.8.0

  • Rehan

    Hi, I tried to follows the steps exactly. but its always gives me 404 Not Found

    • Rehan

      Now it’s working when clear cache..but let me know one thing how can i assign template for this page because it’s displaying on blank page.?

  • sam

    where is the output of this module?

  • sam

    where is the output of this module??

  • Michal

    on Magento works perfectly. Much better than 99% of other tutorials. Thanks

  • Great instruction, thank you very much! Was able to get it working, it’s fantastic!!

  • Tarun Nagpal

    Can you please explain me how you did the 3rd step. ?

  • dipa

    is not work for any one help.. i follow all step..

  • Rabiul islam