• Skip to primary navigation
  • Skip to content
  • Skip to footer

RedChamps

RedChamps Blog

Main navigation

  • Magento 1 Extensions
  • Magento 2 Extensions
  • Visit Store

Magento 2 Directory Structure

Magento, Magento Training · June 25, 2020

While working with Magento customization and development. One should have knowledge of the Magento directory structure to easily locate the required files or directories for theme or module.

The whole Magento structure can be divided into the following types: 
1. Magento root directory structure
2. Modules directory structure
3. Themes directory structure

Let’s have a brief look about Magento Root Directories structure:

1. app

This directory is recommended for Magento components development. It contains:

  • design – contains themes files like phtml, CSS, JS, etc for frontend and adminhtml area.
  • code – contains modules related files that are not installed via composer.
  • etc – contains Magento framework configuration settings files like config.php (modules enable/disable setting), env.php (database connection related setting) etc.

2. bin

Contains an executed file that allows managing Magento using CLI. Like command-line tools Magento but it could be more.

3. dev

It contains test scripts and development related tools. It also store functional test which are run by Magento Function Test Framework.

4. phpserver

Run Magento with PHP builtin web server using “router.php”. To launch a built-in web server:
php -S 127.0.0.1:8082 -t ./pub/ ./phpserver/router.php

5. generated

It contains the generated PHP files (Factories, Proxies, Interceptors, DI configuration). By default, if the class is injected in the constructor, the code will be generated by the Magento to create non-existent classes.

6.  lib

Used for Magento library files. There are some required libraries that Composer does not load. These reside in lib/ and include javascript libraries and a few PHP libraries.

7. pub

This directory is used to access Magento static files. It contains the following directories: 

  • errors – stores the error pages.
  • media – stores all media files like images for (product, pages, etc.). Basically, everything that is uploaded through Magento admin UI.
  • static – stores Magento themes generated files like CSS, HTML, js etc

This directory can be specified as a website root in Nginx config or in the apache config.
Various Magento directories contain “.htaccess” files (including root and pub), which allow you to configure apache for a specific directory. Nginx does not support .htaccess.
For Nginx, Magento has a nginx.conf.sample file, which is an example of Magento configuration for Nginx. This file can be copied, modified, and include the main Nginx configuration file.

8. Setup

It contains code related to the Magento setup wizard.

9. update

It contains Magento standalone updater application. In some cases, we need to update the Magento updater application to updating the Magento components. For more details

10. var

It contains all the temporary files. Consists of: 

  • cache – contains cache files if the cache utilizes the file system as storage.
  • page_cache – contains FPC (Full Page Cache) files, if FPC utilizes file system as storage.
  • log – contains Magento logs.
  • report – contains Magento error/exception files that were not intercepted by code
  • session – contains session files
  • view_preprocessed – contains style generated files and minified HTML

11) vendor

It contains the installed composer packages.
When Magento is installed via the composer or using the official site’s archive, then all the standard Magento modules and Magento Framework are located in this folder. 
In case you install via the official GIT repository, which is recommended only for contributing, then Magento Framework will be located in the lib/internal folder, while the default modules – in the app/code folder.

 

  • Facebook
  • Twitter
  • Google+

Filed Under: Magento, Magento Training

Sanchit

Sanchit is a Magento 2 developer at RedChamps, while not working he loves to read about new technologies going around in web development

Footer

Follow Us ON

  • Facebook
  • Twitter
Copyright © 2025 • Powered by RedChamps