Create new module “HelloWorld” – in Magento

Do you want to create a new page in Magento ? or Do you want to create a new module in Magento ? If yes, Then ok, just spend 10 minutes and follow below steps.

Objectives: I will create a new page in Magento whose output will be “Hello World ! I am a Magento Guy..”.

Target: Create a new module called “HelloWorld”

Step 1: Module Declaration

Create app/etc/modules/M4U_HelloWorld.xml and write below code

<?xml version="1.0"?>

Step 2: Module Configuration

a. Create a controller class app/code/local/M4U/HelloWorld/controllers/IndexController.php

class M4U_HelloWorld_IndexController extends Mage_Core_Controller_Front_Action
    public function indexAction()

b. Create a Block class app/code/local/M4U/HelloWorld/Block/HelloWorld.php

class M4U_HelloWorld_Block_HelloWorld extends Mage_Core_Block_Template
  // necessary methods

c. create configuration xml in app/code/local/M4U/HelloWorld/etc/config.xml

<?xml version="1.0"?>


Define Frontend Template :

1. Define page layout in app/design/frontend/M4U/default/layout/helloworld.xml

N.B: Use default instead of M4U as template location if you use default design packages. Means create file in app/design/frontend/default/default/layout/helloworld.xml

<?xml version="1.0"?>

	<layout version="0.1.0">

			<reference name="root">
				<action method="setTemplate"><template>page/1column.phtml</template></action>
			<reference name="content">
            	<block type="helloworld/helloworld" name="hello" template="helloworld/helloworld.phtml"/>


2. Create template file app/design/frontend/M4U/default/template/helloworld/helloworld.phtml and write down

N.B: Use default instead of M4U as template location if you use default design packages. Means create file in app/design/frontend/default/default/template/helloworld/helloworld.phtml

Hello World ! I am a Magento Guy..

Hey, new module is ready to run and hit browser with url

and see result.

That’s it……..

Is it easy or not ? what you think ?

Coder, Please at first try yourself.

Ohh.., Still are you facing problem ? Lets download full module source code from left panel “BOX” section or let me know.

Note: I have upgraded HelloWorld module source code of BOX widget. So it will resolve the problem which was faced by some guys.

168 responses to “Create new module “HelloWorld” – in Magento

  1. Hi,
    Its not working with me. I have configure all the things as mention. But it doesn’t show “Hello World ! I am a Magento Guy..”.
    It seems IndexController does work properly it calls default layout of megento. Url hellowrold working fine but output is as per need.

    • Hey, you may placed your design related xml and phtml files in app/design/frontend/M4U/default/ location. But you didnot assign right package name(M4U) in admin. So you should use app/design/frontend/default/default/ as template location. I updated post, please see again. Hope it will work. Otherwise let me know, i can send you code files.

  2. Hi,
    I am having trouble getting this to work on my test store.
    Any chance to get in touch offline and work on it together? I really need to get this running.

  3. I am trying to develop a module – I think I followed all the steps correctly but nothing happens when I hit the URL. It would be great if I can contact you online – I can give you access to it so you can direct me to what is wrong – and off course I will pay you for your time. I could not fund an email to send you information directly.

  4. I tried your example for the frontend only with my namespace but i get 404 error. Folder structure is

    • Your folder structure is ok, but you should assign your new design namespace as design package name in admin under configuration tab. I have tested my source code and works fine. You just try to follow my post, hope you will get result. Otherwise let me know details.

      • Hi Moinul,

        Thanks for the quick response. I happen to find the error…

        When i add the below lines in app/code/local/BW/HelloWorld/etc/config.xml i get the 404 error ELSE, i get a 2 column layout…


        Any idea where is it going wrong?

      • Ok you can delete my previous comments as after following the exact codes, i got the example working… Thank you very much for posting and keep such an informative site online!!

        Regards ,

  5. I like to develop a module.I followed your instructions .But when executing the module in frontend i got a error page in the browser.Could you provide me the right solution.

  6. i downloaded the zip file and uploaded it into my folder . But still am getting the 404 error..

    • Please again see your file structure. I tested source code. I know everything is ok, just try to follow step by step. Hope you will get result. Otherwise explain details

  7. First of all I want to thank the author for his wonderful effort on developing new module in Magento. Guys I have tested this module and It works perfectly. It worked for me in just single attempt. All you need to do is to “Follow the instructions VERY carefully”. Thats exacty what I have done.


  8. Dear i have used the files provided by you, but i am able to access the heeloword module.

    IT is showing Whoops, our bad… error.

    Can you please help me?

  9. also tell me one thing that .phtml file will be placed directly in template folder or we have to create a folder name helloworld and put into that folder.

    • Yes, you have to create new folder name helloworld. I know my code is ok. You follow my instructions and read carefully. Hope you can do it.

  10. I did use your exact guidelines. And tried the source code of yours too (there you have put the .phtml file directly in template folder). Tried in both ways.

    But I get the 404 Not found error.

    I am using foo2 theme. So i did put thoses 2 files in f002 instead of default and tried. but it dont work. Even I did put them in default folder as in yours, but still it dont work, why is it?


  11. I did use your exact guidelines. But I get the 404 Not found error.
    version could be a problem?


  12. Pingback: Magento, Magento, Magento « Redbeard Technologies Software and Systems Development Blog

  13. Will try this, thanks for blogging it.

    What might be the cause for some ppl not to be able to get this to work, is all the in Step 1. I’m pretty sure this is not correct. 🙂

  14. Hello All, I have updated source code. Hope It will resolve the problems which have been faced by some guys.


  15. This code is working fine without any error.


  16. I have followed exactly the directions in your post, but I still get 404 error.

    I am using XAMPP on Windows 7 and vhost to modify URL

    I am really appreciated if you give me any ideas?


  17. Sorry, I forgot clear the cache folder. It works perfectly now.
    You can help me by deleting the previous comment.

    Thank you,

  18. Hello all,

    This code is working very fine in fresh magento setup. I have one customized website in magento, In which different package name (Not a default package name). So this module is not working.

    Please give me some solution or advice.

    Thanks in advance,

  19. This module in my system is showing Controller file is loaded but class does not exist

    Can somebody or moil explain what could be the problem .

    But i have do that


  20. Jignesh Can you help , In my default package it is not working , please read the above comment of mine


  21. Anyone can give me his gmail or yahoo id to tell me what could be the problem i would be very thankfull to him


  22. Hi,
    I was followed exactly what you wrote above, but always I was redirect to 404 error page.
    1. Go to System->Cache Management
    2. Select Refresh from the All Cache menu
    3. Click Save Cache settings

    After doing this its stared to work!. You have to add this also in this post for newbies like me.

    Many thank and regards,

  23. yes, that was the same problem I faced

  24. Prakash,

    I got this error when there were not opening PHP tags () in my IndexController.php and HelloWorld.php files.

  25. Dada, ami Dhrubo. ami khubi bipod-e porci, amar admin-e ekta module add korte hobe, apni to module add kora dekhaichen, kintu oi module ta admin-er menu item hisebe kivabe add korbo dekhan nai,jodi ai bepere help koren tahole vai amar jonne khubi lav hoy,

  26. Thankx to the author….guys its working fyn….initially i got sme problem like whoops ,bad…but then i refreshed cache and everything went alrite……if u r facing the same just refresh ur cache….

  27. Hey man, you have a great blog, I am currently working on the magento project with multiple seller/merchant account facility. I have a very hard time doing all these because I am new to Magento. So I really could use your help. can we work on this together online. it would be a great help for me.

  28. Hey, It works for me, praise the lord. Thanks for all.

    In addition to above steps, I have created page from admin side (CMS->Managepages) and used this code {{block type=”catalog/product_new” template=”helloworld/myview.phtml” }} to view to my custom module in browser.

    I think you are all known about this, since I am new to CMS tools, I didn’t get idea 

  29. Great Tutorial Mate!
    But can you please describe little bit more if we want to add a big module in Administration!
    Actually i am building this website and need to add new module within its front end and back end!
    Any help would be appreciated!


  30. Thanks a lot man.At first it didn’t workout but after clearing the cache it works fine. Great post. keep it up…..

  31. Pingback: ::World Web Corner:: Simple for human::

  32. Cassio [Brazil]

    Gratz man! It’s working! Grate job! Very, very thanks!

  33. All work!
    Recache all in adminCP!

  34. Leonardo Cito

    Hello Binod. How are you would how are you getting on with your multi seller /vendor extension in Magento? Please let me know.

  35. Hi , I like your module tutorial but it lacks explanation like in XML files.

  36. you r super.thanks

  37. just follow instruction and download will work

  38. it is possible to copy the viewAction from CatalogController.php to create new view of view.phtml into newname.phtml i have created copy of viewAction to reveiwAction and also it was run good by using
    but i have created new template review.phtml
    then which part we want to change in the catalog.xml file 😦

  39. Thank you very much!
    It work well! This tutorial saves me much time 😉

  40. hi image zoom not working in magento anyone help me

  41. Hi

    I copied everything without doing any changes but I got the same error as I got with the other tutorial:

    you can check it out:

    thank you

    does anyone have an idea?

  42. Hi Moinul Islam,

    I have follow the your instruction it should be work on admin panel is fine.but still now i am not getting front-end display.i have hit this url at the time browser page automatically re-direct to the admin home page or login page i am not getting my result.Please help me.

  43. Remember to God before doing any work
    Than it will be all is well !!!1

  44. Thanks Moin Bhai …!!!

  45. extremely stupid explained. not understandable:(

  46. Thanks It is working . Can u guide me how i can access magento table data. Thanks in advance

  47. James Irving-Swift

    Great guide, I found it very useful 🙂

  48. Hey Thanks………. Its Working

  49. Hi
    how i can call helloword.phtl output in any of page.

  50. Just as a side note. After some 1/2 a day I found that on a multilingual Magento Installation the modules shows as 404 error when accessing as
    but works fine as
    e.g. /index.php/gb/MyModule/
    (Magento 1.4.1)
    I hope this saves someone some time ….

  51. This is working fine but i want to add another module in my magento site.
    i have created another Module just change the Name means that I have replaced “HelloWorld” to “CategoryDescription” but this module is working. if u have any idea then tell me please.

  52. This is working fine but i want to add another module in my magento site.
    i have created another Module just change the Name means that I have replaced “HelloWorld” to “CategoryDescription” but this module is not working so please help me……….

  53. Assalam o alaikum

    JazakAllah, bundle of thanks

    it works fine for me:)


  54. Pingback: To add a module in magento « Venkatraja's Blog

  55. Pingback: Magento Themes and Magento Extensions Create new module “HelloWorld” – in Magento

  56. thanks..!! Nice… one…

  57. I googled but after some find this tutorial.Its really a nice tutorial.

  58. thanks for post this artical

  59. Nice works dudes. It works.

    keep sharing.

  60. Thanks… a lot…………..

  61. i have face some error . the error details

    There has been an error processing your request

    Exception printing is disabled by default for security reasons.

    Error log record number: 921930541
    please send me solution to the problem
    thank you

  62. Thanks….. it works good

  63. this is very clean way to explain each and everything
    thanks a buddy

  64. spletno oglaševanje

    Nice one, i dont know why Magento documentation is so bad,
    I have to learn it from blogs like yours.
    Do you know any good reference book worth buying it?


  65. worked perfectly ! nice article. keep them coming

  66. I’m newbie in Magento. How to add new page on customer account dashboard? I’m used Magento ver.

    Thank You

  67. The best magento module tutorial ever men.

  68. Hi Folks,

    Thanks for this tutorial, I shared it with a friend as it was really useful.

    I just wanted to say that a couple of the problems above, especially the controller class error could be caused if you don’t have a <?php declaration at the top of each php file.

    Simon Rowland (software engineer @ Singing Horse Studio).

  69. Shukriya Bhai Jaan

    The great tutorial.if any body found the “magento 404 not found1” error then please refresh your cache using the link given in admin panel.

    Thanks again.

  70. Thanks, Its working for magento

  71. Pingback: How to make a custom Magento payment extension for an external gateway « Junaid Bhura : Freelance web developer and consultant specializing in PHP-MySQL, XHTML-CSS and Open Source technologies

  72. Hi I have used your exact guide line but now it is show error 404

  73. thanks for this tutorial, i’ve made a list of tutorials to do more:
    i hope it will help.

    Pierre FAY.

  74. Thanks Moinul, you have posted a very benificial tutorial specially for the beginners. The best part is that each and every line has been described in a neat and clean way.

  75. hey thanks a lot… 🙂 it worked at first try.. 🙂 awsome way to explain to ccreate a new page/module .. Thanks a tonn again

  76. reflectionsfromtheshadows

    i’m a complete beginner to magento, and a little rusty with php.
    i’m currently not getting past the 404 stage, though initially i did get a template page but without anything in the main body of it.
    can you suggest whether it would be a problem that i built the magento folder (using the downloader wizard) directly into the /var/www root, so when you say to navigate to i don’t have a projectname component to my path. I currently have to browse to http://servername/index.php to start my magento.
    thanks if you can understand this and advise if it is a problem.

  77. Thank you mister, this is really great.
    I really appreciate this, especially your effort for
    creating and uploading in Box. It is so much
    easier to start when you have referent example.

  78. Pingback: Using Silverstripe as CMS behind Magento – Part 2 | 16is10

  79. Thanks for the post, I downloaded the module and it works.

    But for me is very confused because you are using “helloworld” for everything (name of the module, name of the block file, name of the block class, name of the template etc) so I don’t know what are you referencing exactly in the xml files.
    For example , if I can change block class name from M4U_HelloWorld_Block_HelloWorld to M4U_HelloWorld_Block_HelloWorld2 (I just added a “2” in the end)…What files and what configuration code should I change?


  80. Great…Its Working…Really Good…
    Thank you soooo much for such a Nice help…

  81. hi,
    i’m a complete beginner to magento, and a little rusty with php. it is really good to me it s work for me .
    but i want to show only our message without anything i.e. header ,left, right and footer
    what should i do for this

  82. Thanx your code is working fine

  83. The code in your source files is completely different to that displayed on the page…

  84. Thanks dude, It really helps me… Thanks alot for posting this kind of useful code.

  85. Hello.

    the working of my module in localhost is fine but when we upload into the server its gives the same error 404 not found. WHY?

    Please help me its very urgent

  86. done thanks

  87. I have used same file structure as you describe over here and also clear the cache but still don’t show any message on screen.
    I am using magento 1.

  88. Thanks for this article, It’s very useful for new developers who learn about magento Modules.

  89. Hi … just a query!

    when I declare block class tag and without rewrite just as this it doesn’t work

    Could you plz explain this behaviour?

  90. Thanks for the Article it worked… Thanks a lot..

  91. I follow all the steps Rigth
    as Pin_Api. I hit the url don’t get any error.But no message in the page.It was blank…..any help


  92. Hi friends,

    i have trouble multi-currency with Paypal configuration .
    Advance thanks

  93. Pingback: How to make a custom Magento payment extension for an external gateway | Junaid Bhura - Wordpress, Magento web development studio Bangalore

  94. those who get page not found error 404 then goto admin side system->catch management-> and clear all catch and refresh front side

  95. You need to put in the controller.

  96. Pingback: Module Development Magento « rajeshgoudblog

  97. Pingback: Magento Custom Module Creation « rajeshgoudblog

  98. I follow all the steps given above.. but when executing, it shows 404 not found 1 error message. and also in admin page when click “advanced” link it does not show M4U_HelloWorld to know the status “active” or “deactive”..

  99. Friend,
    Its working fine but when we upload into the server its gives the same error 404 not found.

    Thanks .

  100. I want create new block in magento can you help me ?

  101. it is executing properly !!!!

  102. nice one …
    it got executed 😉
    thanks . . . .

  103. I wrote this module 3 times… The 1st time I got a blank magento page, I thought it was an error I made. I rewrote it 2 more times, with the exact same result. If I enter the URL address it does not give me 404, it just gives me the blank page. If I change a character in the URL it correctly gives me error 404. I cleared the cache via the console and the system, and in both cases it still just gives me a blank page.

    I am running Windows x64, with the latest WAMP and latest magento install files, am I missing something?

  104. After a rewriting this and getting the same result I am very close to giving up with Magento, I switched browsers from Chrome to Firefox, okay now I can login to the /admin section.

    I type the URL to access it, and it does not say 404 not found, it simply gives me a blank Magento page with no content. I follow the steps, and just keep getting the same problem am I missing something?

  105. m follow all stem and run the code but it`s not working please help me and m using magento 1.5 version……………..


    I use enterprise with multiple stores, and I cannot get this to work.

    I’ve tried clearing the cache. It just simply won’t work.

    Magento ver.

  107. Thanks for the tutorial its worked after i put all the file from may edit your tutorial so people can fix it first time without downloading your source code.and give some simple explanation of each Blocks function.

    Thanks again 😉

  108. Great!!. It is working fine. In the first time itself I got the correct out put just after clearing cache. Thank you. Keep on update such great tutorials..

  109. I had read all the thread, flushed the cache, but it’s still throwing the 404 error… My magento version is 1.7 (maybe it’s matters?)

  110. Siddakasivareddy

    Thanks for this article, It’s very useful for new developers who learn about magento Modules.

  111. hey hi moinul
    I used ur source code.exact i follow ur steps.but i occure following error

    “404 error not found or configure”

  112. hey hi
    tell me the role of following folders

  113. this module is not showing helloworld.phtml file’s data on frontend.

  114. After clearing cache, I am being redirected to error page: (/errors/report.php) Where it is saying:

    There has been an error processing your request
    Exception printing is disabled by default for security reasons.

    Error log record number: 1056778645540

    You didn’t answer @dinesh comment for the same issue:

  115. Muhammad Ashfaq

    Sir My controller not calling layout that define in my theme frontend/default/wiper/default/layout/helloworl.xml and (wiper is my default theme). when i goes to http://localhost/magento/index.php/helloworld/ display nothing.
    but when i echo some thing in my function indexAction{
    echo “this is index function”;
    “this is index function ”
    This will show rather than showing block info.Please Help me I am new in magento. Thanks In Advanace.

  116. great ……………..

  117. Hey Moinul,

    Very nice Article, it would have been nice if you can also elaborate the naming conventions and what each XML tags are for..

    ex –


    here this tag refers to frontname, classname, modulename, blockname.. its a bit confusing.. if you can just explain those, it will be really helpful.

  118. Tnx !!! It’s working 🙂 my first magento module

  119. hey hi…. thanx for this code…. but i tried to go thrugh the link as u said… bt its nt working… its showing me……

    Whoops, our bad…

    The page you requested was not found, and we have a fine guess why.

    so plz help me out…… i m waiting for ur reply….. 🙂

  120. Pingback: How to start Magento ecommerce development ? – for Beginner | Magento-4U

  121. hello everyone,
    can any one suggest me, any best advanced ajax cart extesion for magento.

  122. Thanks working perfect for me.

  123. I tried all these tips given above but still It shows 404 error.

  124. Hi,
    Every body are talking about a zip file which they downloaded and made them happy! Is there any link?

  125. I really like it when folks come together and share ideas.
    Great blog, keep it up!

  126. Hello am using Magento 1.8version am trying to display Goldrate Module table display on menu category but i do not know how to do that where to put to coding can u please help me

  127. hello, i add this module in magento but when i see the page then display only “class M4U_HelloWorld_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(array(‘default’)); $this->renderLayout(); } }” and There has been an error processing your request ……this type of error

  128. Good tutorial ,Thanks a lot 🙂
    Its working with defautlt theme package .But its not working in my custom template package ? Iam beginer to magento . Please help me 🙂

  129. Sorry for trouble , its my mistake now working fine thanks a lot 🙂

  130. Still no download link?

  131. Hello, can i get a quick help from you, i am integrating new theme on the existing store but not able to migrate 2 existing modules from old template. Ready to payout, if you wish.

  132. I am on magento 1.8 and i fixed my 404 error by doing the following. inside Magentotutorial_Helloworld.xml they tell you to put this code in “local” since i do not have a local folder i put mine into the community folder. Change the code to this and it will work. “community”

  133. codePool inside XML.

  134. Guys i have a solution for all of you who are facing problems.
    you just need to change the directory structure for helloworld.xml and
    helloworld.phtml as follows.

  135. Everything is very open with a clear explanation of the issues.
    It was definitely informative. Your website is extremely helpful.
    Thanks for sharing!

  136. Simplest modules ever, good for beginners, Thanks you for your sharing

  137. Pingback: Fix Magento Error Log Record Number Location Windows XP, Vista, 7, 8 [Solved]

  138. Pingback: Fix Magento Print Errors Windows XP, Vista, 7, 8 [Solved]

  139. where i can find the downloading file ????
    if its posible send me the file to this mail id…..

  140. pls let me know how i can upload this extension via Extension Manager in magento .

  141. very effective and useful tutorial. Thanks Moinul. Proud to be a Bangladeshi.

  142. I don’t see any download links 😦
    “Lets download full module source code from left panel “BOX” section or let me know.”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s