Magento is based on Object-Oriented Programming (OOP) structure concept, made with MVC design pattern in PHP scripting language. It has a robust, flexible, and well-defined directory structure that makes it an efficient ecommerce platform for technical users.
In this guide, we will focus on Magento folder structure, learning its details and finding out how the folder structure works.
We will also discuss the top-layer of Magento folder structure and explore the depth of necessary sub-directories. Let’s start by naming “RootDirectory” as the installation directory of the Magento platform.
Magento Folder Structure
In Magento 1.x, the default files and folders included in the main directories are as follows:
/app – This is where all the php code for the Magento platform resides. It contains the configuration files related to Magento application like the database, core, modules, themes, and files related to programming languages.
/dev – The Magento directory structure includes the Magento Test Framework (MTF) files as well. The MTF is a tool that can run automated functional tests, to assist in the development and implementation of Magento modules. These test files can be found in this /dev directory.
/downloader – It is used to download and install the extension from Magento connect. It is also used for the installation and upgrading of Magento through the web browser.
/errors – This directory contains different error processor and template files like 404 error. Usually, people do not touch this directory.
/includes – It includes some middleware code files. All model files parsed and moved into this folder. Once you make any changes in a model file of the module, first it is parsed and then moved into the /includes directory.
/lib – The external PHP code library used in Magento.
/media – This is storage directory of the Magento media files like generated thumbnails, uploaded product images, etc. It is also used as the container for importing images through CSV or other import/export tools.
/shell – This is the dedicated folder where Magento scripts are stored. Some scripts like indexer.php or log.php can be found in the shell directory, allowing you to perform actions using Command-line Interface (CLI).
/var – The var directory plays an essential role in Magento directory structure. It mainly contains temporary files and data like cache, error, log, session, and locks.
Magento 2 Folder Structure
Magento 2 folder structure has been changed a lot from the previous version of Magento platform. If you navigate through the root directory of Magento 2, you’ll see the following folder structure:
/app – This folder contains the core files of Magento 2 including configuration, modules and themes files.
/bin – It contains the Magento 2 CLI feature. Using CLI would require SSH access to the server. The Magento 2 CLI can help you in installing modules, upgrading the application core, reindexing, compiling, etc.
/dev – This directory contains various tools for developers such as Magento Test Framework (MTF).
/lib – This directory contains libraries packed separately from the Magento 2 core libraries.
/phpserver – The phpserver folder contains Router.php file.
/pub – This directory contains generated static files and site media. It should be set as your web root on the server side. As the name of the folder says, it contains all the publicly accessible files.
/setup – Several important packages such as the performance toolkit are available in this setup directory.
/var – Same as Magento 1, the var folder contains raw cache files, logs, sessions, and reports.
/vendor – Vendor directory is generated by composer using composer.json file. This folder includes various packages that have been defined under composer.json file.
Boost Your Magento Store Performance by 5x Times & Maximize Your Sales
Our fastest Magento hosting can help you in growing your business revenue by 500%
Fayyaz is a Magento Community Manager at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at firstname.lastname@example.org