This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

Magento Folder Structure: Overview of Directories and Libraries

Updated on  May 22, 2018

3 Min Read
Reading Time: 3 minutes

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.

Magento Folder Structure

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:

/RootDirectory
        /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.

          /js – This directory contains the pre-compiled libraries of the JavaScript codes included in Magento.

          /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).

          /skin – This is where images, javascript files, CSS files, and flash files reside. It also includes the skin files for installation of skins and administration templates including media files related to the design of the frontend and backend.

          /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:

/RootDirectory
           /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.

Share your opinion in the comment section. COMMENT NOW

Start Growing with Cloudways Today.

Our Clients Love us because we never compromise on these

About The Author

Fayyaz Khattak

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 m.fayyaz@cloudways.com

Stay Connected:

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.