Magento directory structure

Magento aims to decrease the amount of time that developer uses for manually including of files into the different modules and on the other hand to decrease the amount of files, which has been load on a single request. In order to do that it uses specific directory structure, xml configuration and some additional configuration under the app/code/Mage/Core.
The most important directories under the Magento root folder one are presented with orange in the figure on the right. At this level in the hierarchy the directory naming is based on keywords.
The files under the directory ‘app’ are, as it can be suggest from the name, build the entire functionality of the web shop application, they are never addressed directly by the browser.

The ‘js’ folder contains all JavaScript libraries used in Magento. The mainly used library in the Magento 1.xx versions is Prototype, therefore the usage of the other popular JavaScript libraries e.g. JQuery should be taken careful, because it can cost conflicts. The expected JavaScript framework for Magento 2 is JQuery.

The ‘lib’ directory contains different libraries – Zend, Varien are the libraries implemented by Magento and other third party libraries. In the Varien library for example contains the autoloader, which loads the PHP files called from the factory methods.

The ‘media’ folder contains the uploaded files for given module. For example the products and categories images are placed under the ‘catalog’ directory.

The ‘skin’ directory contains three design areas/folders ‘adminhtml’, ‘frontend’, ‘install’ and each of them contains images and css files specific for the current area. They are always accessed from the browser.

The ‘var’ directory contains the dynamically-created and temporary files such as cache, logs, session storage. This folder can be completely deletes Magento will recreate it, if it is needed.

The files under the root directory are colored with blue in the figure on the right. The file ‘.htaccess’ contains the host configuration for the apache. It is mainly used for declaring URL rewrites e.g. if you enable the URL rewrites, URL from the type ‘http://xxx/webshop/admin’ will be automatically translated to ‘http://xxx/webshop/index.php/admin’. In the webshop the URL rewrites can be enabled. The index.php is the initialization file – this is the only entry to the web shop application. And cron.php is used for scheduled job functionality.

The most important folder for the proper Magento system functionality is the ‘app’ folder: It is presented in the figure in the right the three folders underneath have different responsibilities to the end system functionality.
The ‘code’ directory consists of the 3 code pools in Magento:

  • core – this is the base, the core Magento functionality. These files should not be changed from the custom modules.
  • local – this is for Magento custom modules in development phase
  • community – this is for Magento custom modules in production phase

The design folder divided the same as the skin into three areas/folders ‘frondend’, ‘adminhtml’ and ‘install’. Each of them consists of its own templates(.phtml) and layouts(.xml) files.

The ‘etc’ folder contains ‘modules’ folder containing the register .xml file for each module e.g. Company_Module.xml. Without file in this directory all files from a certain module are not going to be evaluated from the system.

The ‘locale’ folder contains the different language possibilities and the map file (.csv) is for the different language files.

Article Name
Magento directory structure
The directory structure of Magento is the key starting point for every beginner Design or Plugin developer. This article aims to describe this directory structure in easy and understandable way so everybody can get good start.