Back to Top

Magento 2 Area codes

Updated 9 April 2024

Introduction

In this blog, we will discuss the different area codes used in Magento 2.

Area codes

An area is a logical component that organizes code for optimized request processing.

The Adobe Commerce and Magento Open Source framework (Commerce framework) uses areas to streamline web service calls by loading only the dependent code for the specified area.

Each of the default areas defined by the Commerce framework can contain completely different codes on how to process URLs and requests.

The different Area codes in Magento are

Searching for an experienced
Magento 2 Company ?
Find out More
  • Admin (adminhtml)
  • Storefront (frontend)
  • Basic (base)
  • Cron (crontab)
  • Web API REST (webapi_rest)
  • GraphQL (graphql)
  • Web API SOAP (webapi_soap)

Admin (adminhtml)

The adminhtml is an area code that contains the files that define the appearance of the Admin side.

Storefront (frontend)

The frontend is an area code that contains the files that define the appearance of the Client side.

Basic (base)

The base is an area code that contains the files which contain code used on both the Admin and Client side.

Cron (crontab)

To create a cron job you need to create a crontab.xml file under the etc folder where you can define your cron jobs.

The crontab area will always be loaded by the \Magento\Framework\App\Cron class in cron.php

Web API REST (webapi_rest)

The webapi_rest area in Magento contains files that define a set of functions that a developer can use to perform requests and receive responses.

GraphQL (graphql)

The graphql area is used to create and manage the graphql API.

In Magento 2, GraphQL is a new feature whose primary focus is to speed up and boost the APIs, their flexibility, and their effectiveness. It allows developers to query and mutate data in Magento’s database using a standardized syntax.

Know more about GraphQL.

Web API SOAP (webapi_soap)

The webapi_soap area is used to create and manage the soap API.

How 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 your extension works in several different areas, ensure it has separate behavior and view components for each area.

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

You can enable or disable an area within a module. If the module enabled then it injects an area’s routers into the general application’s routing process.

Next Blog -> Magento 2 Module Registration

Previous Blog -> Magento Commands List

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home