Magento 2 Modules File Structure

Magento 2 Modules Files Directory

Module files di Magento 2 terdapat di 2 lokasi:

1. app/code/<VendorName>/<ModuleName>/
2. vendor/<vendor-name>/<module-name>/

Vendor Name — adalah nama module/vendor yang mengembangkan modul. Dalam beberapa kasus, nama vendor mungkin sama dengan nama perusahaan pelanggan. Oleh karena itu, sebelum mengembangkan modul baru, nama harus disepakati.

File modul yang dikembangkan sesuai pesanan atau modul dari perusahaan lain yang diinstal melalui FTP terletak di folder app/code.

Folder vendor berisi modul root Magento 2, serta modul yang diinstal menggunakan Web Setup Wizard atau Composer. Anda akan menemukan modul root Magento di folder vendor/magento.

Menarik untuk diketahui:
Di repositori Magento 2 (dev branch) di GitHub (https://github.com/magento/magento2), semua modul root ada di kode aplikasi/folder Magento. Dan semua library PHP ada di lib/internal/Magento.

Magento 2 module structure secara garis besar seperti di bawah ini:

├── Api // PHP interfaces
├── Block // PHP view classes, in MVC terminology. They contain methods used in .phtml templates;
│    ├── Adminhtml // view-classes of the admin panel;
│    └── SomeBlock.php // view-class (block) used in the storefront;
│
├── Controller // PHP controller-classes (part of MVC);
│    └── Adminhtml // controller classes used in the admin panel;
│
├── Cron // PHP classes, which methods are called when performing cron-tasks;
├── Helper // PHP classes with auxiliary logic. Their methods are used in different parts of the module;
├── Model // PHP model classes (part of MVC);
├── Observer // PHP observers classes;
├── Plugin // PHP classes of interceptors;
├── Setup // PHP classes used when installing, updating and removing the module, allow you to change the data and structure of the database;
├── UI // PHP classes that work with UI-components;
├── etc // module configuration files;
│    ├── adminhtml // configuration files that apply only to the admin panel;
│    │     ├── admingws.xml // is used for the delimitation of rights at the Store View level (used only in Enterprise version (EE) of Magento 2);
│    │     ├── di.xml // plugin settings, virtual types, rewriting models .;
│    │     ├── menu.xml // is responsible for building the menu;
│    │     ├── routers.xml // route settings;
│    │     ├── system.xml // building a settings page Stores> Configuration;
│    │     └── events.xml //observers settigns;
│    │
│    ├── frontend // configuration files of the storefront;
│    │     ├── di.xml
│    │     ├── events.xml
│    │     ├── routers.xml
│    │     └── events.xml
│    │
│    ├── acl.xml // settings for delimitation of rights in the admin panel;
│    ├── config.xml // default values ​​for fields in Stores> Configuration;
│    ├── crontab.xml // settings of cron-tasks;
│    ├── di.xml
│    ├── webapi.xml // REST API settings;
│    └── widget.xml // widget settings;
│
├── i18n // CSV localization files;
│    ├── en_US.csv
│    └── uk_UA.csv
│
├── view // view files: layouts, templates, js, css, html, images, fonts;
│    ├── adminhtml // files used in the admin panel;
│    ├── frontend // files used in the frontend;
│    │    └── layout // xml layout files;
│    │    └── templates // phtml-template files;
│    │    └── web // static files;
│    │         └── css
│    │         └── images
│    │         └── js
│    │
│    └── base // view files used both on the storefront and admin panel;
│
├── LICENSE.txt // file with the description of the license according to which the module is used;
├── README.md // description of module functionality;
├── composer.json // file that allows to install the module through composer later on;
└── registration.php // file that registers the module in the system;

Kita dapat explore module magento lain untuk mengetahui fungsi2nya: sebagai contoh dua module berikut:

– Magento_Cms (vendor/magento/module-cms)
– Magento_Catalog (vendor/magento/module-catalog)

About the Author

You may also like these