Basic folder structure for new Magento Extension

Featured Image

When I had first contact with Magento platform, I had to create a custom module for it. I thought to myself – how hard can it be? How wrong I was… I didn’t even know where to start…

Anyway, as I already knew the principals of MVC (Model – View – Controller) architecture, and had fairly good knowledge of object orientated PHP, all I needed was the basic file/folder structure for my custom module.

Just a small notice before I start: there are numerous tutorials / blog posts that explain the contents of those files, and therefore I won’t go into that.

So, without any complications, I give you just that 😀 :

//If you're new to OOP, take a look here:
//Name of new custom module - try to keep at least first letter capital, or there WILL BE truble with Magento's understanding
//In classic MVC architecture, this represents View part of MVC
//This is fairly easy to understand, if not, have fun:
\app\code\local\MyNamespace\Appname \etc
//Contains the most significant part in Magento's MVC architecture - the xml field that will connect all things together
//Intended for files that contain repeatable routines or simple procedural methods
//Same thing as for controller, take a look at the link above
//This was interesting thing to find out what's it for, it's to define custom database tables and process any upgrades to your extension.
//Contains all Modules included in Magento - here's where it all really begins for our module

And I just wanted to give you an idea of how things get connected here.

  1. Magento takes all xml files from “etc/modules/” to know which modules are there, and where are they located
  2. By that location (specified in xml file at “etc/modules/”) Magento includes xml file from “/app/code/local/MyNamespace/Appname/etc” so that it can connect all other things together
  3. The IndexController.php is the next one that’s included, and from there, it’s basic MVC (with slight variations)

I will provide 2 great tutorials that helped me a lot: ActiveCodeline tutorial and Magento Commerce tutorial

Well, I really hope this will help someone, because I know it would help me if I found it… 😀


  1. Hello,

    I want to create my own extension. I need to add my JS file.

    Where I have to add JS file in skin folder?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.