Magento 2 Module File or Magento extension folder structure / Folder structure is too complicated. We are not going to cover all files and folders within Magento 2, but the high-level ones only.
¡How to tell the difference between a folder and directory? Actually, they are the same things. Though, when you refer to a command line interface like Linux it’s more correctly to use ‘directory’ instead of ‘folder’!
Helpful hint: Knowing the M2 folder structure can help you out with the installation of new extensions and custom code implementation. However, you have to acquire tech knowledge enough to perform the work bug-less and independently. If you have no such possibility, hire our installation services. We offer installation services for the whole order, so no matter how many extensions you order we’ll install them all taking into account your unique business needs.
If you navigate to your Magento 2 root, you’ll see the next folders:
Each folder consists of subfolders where the subfolders contain files. Let’s have a closer look at each of the folders:
As well as in Magento 1, the folder contains the main Magento code;
adminhtml and frontend directories;
the /app/design/adminhtml and /app/design/frontend directories contain theme folders with various CSS and LESS files;
the di.xml file contains class mapping and interface preferences;
Note that in Magento 2.2.x and later versions the folder var/generation was removed to the project root and renamed to generated. For more information see here.
The app, lib and var directories were included in Magento 1 too. Magento 2 contains such new directories as bin, dev, phpserver, pub, setup, update, and vendor. For those who have just migrated from the first version, here is a table with the basic purpose of the new directories:
directory | purpose |
app | includes the design folder for themes; the configuration file env.php; |
bin | includes the Magento 2 command line tool named magento; |
dev | includes testing files for the Magento 2 Functional Testing Framework; |
lib | includes various libraries and packages ; |
phpserver | includes router.php; |
pub | includes generated static files, the website media; |
setup | the performance toolkit and other important packages; |
update | similar to the downloader from Magento 1 and contains upgrade files; |
var | similar to Magento 1 and includes raw cache files,logs, and reports; |
vendor | the closest to app/etc/modules. |
¡Bear in view that Magento Enterprise and Magento Professional versions differ in folders!
According to the statistics, you may find helpfull the following questions about magento internal server error and jquery
.
Login and Registration Form