What is Magento's 2 and 2.1 Directory Structure

parksdesign
01-12-2016 14:15

I have gone through the directories of Magento 2 and i found that directory structure has changed significantly. It is important to understand these difference between Magento 1.x and Magento 2. In this post i will describe significant changes of directory and file structure.

Root Folder Structure

First let’s compare root folder structure of Magento 1.x and Magento 2. There are major changes applied at root level. Very first thing you will identify is that some new folders are introduced and some of them are removed.

  • media and errors folder are moved to pub folder
  • skin and js folder are moved to pub/static folder. Now it is easy to maintain static content via CDN.
  • js, css, images are again divided into pub/static/adminhtml and pub/static/frontend for backend and frontend area respectively.
  • dev folder contains various tools for developers such as migration tools and tests. shell is moved to dev folder
  • downloader, includes and pkginfo folder are no more with magento 2.
  • setup directory is for installation process
  • get.php, cron.php and index.php files are moved to pub folder.

 

There are 2 index.php files one in Magento root folder and another in pub folder. You can configure your server to run your application through any of this index.php file. Using pub/index.php is a good option as it will stop access of application files and it is good for security.

eav.php

Database connection settings, backend name, session save settings and cache settings are declared in app/etc/env.php

config.php

config.php has list of active and inactive modules

Theme Folder Structure

Magento 2 comes with very drastic changes on the frontend. Significant changes has been apply on theme structure for performance improvements.

As like earlier version magento 1.x base package ‘app/design/frontend/base/’ will no more exists. Each core module in Magento 2 has new folder introduced which is called ‘view’. This ‘view’ folder contains all module specific files like email template, js, layout xmls, phtml for frontend and backend.

Themes are grouped by ‘vendor’ which we known as ‘package’ in magento 1.x. Theme structure in Magento 2 is like ‘app/design/frontend/vendor_name/theme_name’.

 

 

 

Core module

Magento core components are exists in your_magento_web_root/vendor/magento directory.

Module Folder Structure

In Magento 2 app/etc/modules folder is removed and module’s declaration is moved to app/code/Vendor_name/Module_name/etc/module.xml file. Each module has its own registration.php file in its root. This file is for Magento to identify it as a module.

app/code/core, /local, /community folders are removed and module structure becomes like
[root]/app/code/[Namespace]/[Module]

  • Namespace is a name of a module’s vendor
  • Module is a name assigned to a module by its vendor

Next to Controller, Model, Helper, Block, etc Magento 2 has introduced new folders which are:

  • Api
  • i18n – contains module specific translation
  • view – contains module specific layout xmls, phtml

 

 

Average rating: 0 (0 Votes)

You cannot comment on this entry