Basic Magento Directory Overview

September 28, 2009 at 12:21 pm 2 comments

Important Paths

/ -Directory Root

/app – This is where all the php code for the application resides

/lib – The external code library.

/skin – This is where css and other images reside

That’s the quick overview.

/app

/code – Where all modules reside

/design – Contains both layout xml files and template .phtml files

/etc – Global configuration

Mage.php – Static class Mage, where everything is held together.

Before I move on to the other two directories (/lib, /skin) I’ll explain the directories in this (/app) dir.

/app

/code

/community – Downloaded modules built by Magento community members

/core – The core modules ‘out of the box’ build by Magento

/local – Any module we build ourselves

Within these three subdirectories we find the /Mage directory. This is where all the modules should reside. Also, upon startup Magento includes the paths

  • /app/code/core/ and
  • /app/code/local.

So, by default the system has access to those directories. Now here is the trick: If we create a module ‘RandomModule’ and within that model we create a ‘/model’ directory, we must follow a convention for every class we put inside that folder. For instance a class would be named the following:
class Mage_RandomModule_Model_SomeClass extends Varien_Object { }

With this convention we can call this class anywhere from within the application. Magento will take the name, replace underscores with forward slashes, include that file, then load the requested class, and return an instance of that class. Pretty cool.

As for the individual modules, you will see a directory pattern that all follow, it is pretty simple there. I have noticed that Magento likes to separate their model. For instance, there will be a directory that will ONLY contain classes/methods that query the db and return results. They follow that pretty strictly, I never see methods access db from within a model that is not dedicated to db access. They do that in their practice, we are not forced to do so, but I have tried it, it makes a lot of sense to me.

Thats pretty much it for the /app/code directory for now

/app

/design

/adminhtml -Admin designs

/frontend – Front End designs

/default -This is the default Interface, we can create other interfaces

/default – This is the default theme, we can also create multiple themes

/layout – Contains all the layout xml files

/template – Contains all the template .phtml files

Here, we can create multiple interfaces and themes within each interface. From the admin page in a browser, we assign a theme to each website or store. The power here is that we can create multiple themes, such as spring, christmas, or whatever, then they can be enabled and disabled by a simple click from the admin panel.

This interface/theme pattern is used again in our /skin directory from the root. This assures that when the administrator switches an interface or theme, the appropriate css sheets will be applied.

Also, very cool to me.

Lastly, lets overview the /skin directory from the root directory.

/

/skin

/adminhtml – Admin styles directory

/frontend – frontend styles directory

/default – Our default interface

/default – Our default theme

/css

/images

/js

Notice the correlation of the /skin directory to the /app/design directory.

To create a new interface or theme, we MUST make a new interface or theme in both of these directories or there will be mayhem!

That’s the basic directory structure overview.

Advertisement

Entry filed under: Magento Intermidiate. Tags: .

Models and ResourceModels

2 Comments Add your own

  • 1. Supankar  |  November 13, 2009 at 10:07 am

    Nice blog. The contents are also helpful to learn Magento.

    Regards;
    Supankar

    Reply
  • 2. Anthony  |  January 20, 2010 at 6:33 am

    Your blog is a great source of information for magento developers and for people who wants to learn magento.

    Magento Developer

    Reply

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Posts

Categories

Archives

Top Rated

Blog Stats

  • 5,828 hits

 

September 2009
M T W T F S S
     
 123456
78910111213
14151617181920
21222324252627
282930  

Follow

Get every new post delivered to your Inbox.