Previously, I showed you how to install magento 2.0. To continue the magento development series with Magento 2, today I will show you Magento 2 Theme Structure
As you can see, Magento 2 is still in the development phases. We have gone through the code and found that there are lots of significant changes. These changes mainly happen in folder and file structure. Hence, the post will be divided into 3 main parts:
• Root Folder Structures
• Theme Folder Structures
• Module Folder Structures
1. Root Folder Structures
Magento 2 directory structures have some differences from the previous Magento versions 1.9.x. The major change in the directory structures started from the root folder.
Let’s compare root folder structures between Magento1.x and Magento2.
As you can see, some new folders and some of them are removed.
• media and errors folder are removed 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/frontend for backend and frontend area respectively.
• dev folder contain various tools for developers such as migration tools and tests. shell is removed to dev folder
• downloader, includes folder are deleted
• setup folder is for installation process
• get.php, cron.php
There are 2 index.php files. One file is in Magento root folder and another is in pub folder. That allows you to configure your server to run your site through any index file.
Using pub/index.php is better because it will stop access of application files. Hence, it is good for security
2. Theme folder
Magento2 comes with huge changes on the frontend.
In term of theme, there are two significant changes we can see in Magento 2 including:
• Removal of skin directory from the root
• Introduction of a new directory ‘view’ in the module folder structure which actually completes the MVC structure in more structured way.
we don’t have to create a directory inside skin directory like we did in Magento 1.x,. Instead, we can place all the module specify JS, CSS, Images inside the web directory in each module folder
Themes are grouped by ‘vendor’ which we known as ‘package’ in magento 1.x. Theme structure in Magento 2 is like
3. Module Folder Structures
In magento 2.0,
app/etc/modules folder is removed; instead, module is declared in the new folder
app/code/core, app/code/local, app/code/community folders are deleted and module structure becomes:
• Namespace is a name of module’s vendor
• Module is a name assigned to a module by its vendor
Also, Magento 2 has introduced new folders such as:
• view – contains module specify layout, template
• i18n – contains module specify translation