Areas in Magento2

An area in Magento 2 is nothing but segregation of components in order to help optimise the requests and primarily to organise the code. Whenever a request is received in Magento, the areas are used to streamline the request to specific areas thereby loading only the respective dependent components specific to that particular area. The components are segregated with respect to the areas that it contains only the code specific to that area. The area contains modules only required for that particular areas. For example, when you a request for contact form is loaded, only the frontend area is loaded and not any modules from the admin area are loaded.

Following are the 6 types of Areas in Magento 2:

Magento Admin Panel – adminhtml:

All the code related to the Magento Admin Panel can be found in this area. The codes related to the view of the admin panel can be found in the directory app/design/adminhtml or within the module directory NameSpace/ModuleName/view/adminhtml folder. The XML configurations that needs to be specific only for the Admin Panel are placed in NameSpace/ModuleName/etc/adminhtml folder. Similarly for admin panel, the Controllers and other class files are placed within the Adminhtml folder in order to write features specific to the admin panel area.

Website Store front – frontend:

All the files related to the storefront are located in the frontend area. The view files (layouts and templates) are either placed in app/design/frontend or within the module at NameSpace/ModuleName/view/frontend folders.

Basic – base:

The base folder is used for placing files that are absent in frontend and adminhtml area.

Crons – crontab:

All the cron related files are placed here and the pub/cron.php is the entry point for this area.

SOAP Web API – webapi_soap:

The entry point for SOAP API is the pub/index.php file and the front controller takes care of mapping the request with the class file and method that produces response.

REST Web API – webapi_rest:

The entry point for REST API is the pub/index.php file and the front controller takes care of mapping the request with the class file and method that produces response.

Related Posts