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
- , and files are moved to pub folder.
There are 2files one in Magento root folder and another in pub folder. You can configure your server to run your application through any of this file. Using pub/ is a good option as it will stop access of application files and it is good for security.
Database connection settings, backend name, session save settings and cache settings are declared in app/etc/
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’.
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/file. Each module has its own 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
- 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:
- i18n – contains module specific translation
- view – contains module specific layout xmls, phtml