Basic Magento Directory Overview
This is an old revision of the document!
/ -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 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 /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.