Magento Forum

   
Basic Magento Directory Overview
 
tman_f
Sr. Member
 
Total Posts:  85
Joined:  2008-02-12
 

Hi all, I recently made a document for the other programmers in my company that gives a basic directory overview. I thought it might be useful for anyone that might be new to Magento. So, here it is:

Magento Directory Structure

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

Thats 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
--/admin -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
----- /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
--/admin - 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!

Thats the basic directory structure overview. Let me know if any of this didn’t make sense. I will begin working on some basic coding practices that Zend/Magento uses.

 
Magento Community Magento Community
Magento Community
Magento Community
 
RoyRubin
Magento Team
 
Avatar
Total Posts:  968
Joined:  2007-08-07
Los Angeles, CA
 

Great post! If you can also post this on the wiki, that would be great.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tman_f
Sr. Member
 
Total Posts:  85
Joined:  2008-02-12
 

@RoyRubin : Done.

I am not very familiar with wiki formatting, and for some reason the format is a little strange and boxes show up where they are unnecessary, so if anyone would like to fix the formatting I would appreciate it. Also, if someone does decide to do so, please update this post so we dont have members re-editing the format after it has been fixed.

wiki title: basic magento directory overview.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tman_f
Sr. Member
 
Total Posts:  85
Joined:  2008-02-12
 

Community,

i fixed the formatting issue, so no worries there.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
SebboKleine
Jr. Member
 
Total Posts:  23
Joined:  2008-07-10
 

I’ve got a question about the lib folder. You don’t write anything specific about it.
I’ve made a change to the gd2-lib changing the quality of created images, following a post in this forum:
http://www.magentocommerce.com/boards/viewthread/5290/

But I’m not shure if these changes will remain in there after a Magento update. Can anybody show some light on this.

I’ve read somewhere that you can put changes to the lib-folder under /app/code/local. I tried that, but it didn’t work. Neither putting the gd2-file directly in there nor creating the directory-structure helped. Any ideas?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top