https://embed.notionlytics.com/wt/ZXlKd1lXZGxTV1FpT2lKallUZzJPRFEwWVdZMFpUZzBZMk14T0RabU9EZGtPVEEzWkRJMk1qSTJaaUlzSW5kdmNtdHpjR0ZqWlZSeVlXTnJaWEpKWkNJNklrbGpiM1pzV2pOcU1VUnBRM1ZUUm1WNFRtdHlJbjA9

What are Magento 2 areas?

An area is a logical component that organizes code for optimized request processing. Magento uses areas to streamline web service calls by loading only the dependent code for the specified area. Each of the default areas defined by Magento can contain completely different codes on how to process URLs and requests.

Each Magento 2 module has its own set of configuration files, gathered into the module’s etc directory.

<aside> ➡️ Additions you make to those directory configuration files are applied globally to your module.

</aside>

<aside> ➡️ Areas are registered in the Dependency Injection framework di.xml file.

</aside>

Magento 2 module also has nested configuration directories in the etc directory for any required adminhtml, frontend, API REST, API SOAP, etc specific configuration. Additions you make to files in these directories override the settings in the global configuration files for the respective functionality only.

List of areas

How do areas work with modules?

Modules define which resources are visible and accessible in an area, as well as an area’s behavior. The same module can influence several areas. For instance, the RMA module is represented partly in the adminhtml area and partly in the frontend area.

If the configuration file is located in the directory of an etc/module, its values are located in the global scope. To specify the scope of, for example, adminhtml or front-end configuration, you need to put the configuration file in the etc/frontend or etc/adminhtml folder respectively.

Each area declares itself within a module. All resources specific for an area are located within the same module as well.

<aside> ➡️ Modules should not depend on other modules’ areas.

</aside>

What are the best area practices?