Flow of Magento 2 when user hit store url

  1. The Magento bootstrap file (app/bootstrap.php) is loaded, which sets up the necessary environment variables, including the application mode and error reporting settings.
  2. The Magento application object is created and configured, which involves loading configuration files, setting up dependency injection, and registering the necessary modules.
  3. The request is processed by the index.php file, which sets up the front controller and routes the request to the appropriate controller based on the request path and other parameters.
  4. The router matches the request to a specific controller and action based on the URL path and other parameters.
  5. The controller action is executed, which involves processing the request data, loading the necessary models and other dependencies, and rendering the appropriate view.
  6. The response is generated and returned to the client, typically in the form of HTML or JSON data.

If you’re looking for specific code examples or class references, the Magento\Framework namespace contains many of the core classes and interfaces that are used throughout the Magento 2 framework. Some key classes that are involved in processing requests include:

  • Magento\Framework\App\Bootstrap: The main bootstrap class that sets up the Magento application environment and loads the necessary configuration files.
  • Magento\Framework\App\Http: The front controller class that handles incoming HTTP requests and routes them to the appropriate controller and action.
  • Magento\Framework\App\RouterInterface: An interface that defines how requests are routed to specific controllers based on the request path and other parameters.
  • Magento\Framework\App\ActionInterface: An interface that defines the standard methods that are implemented by controller actions, including the execute() method that is called to process the request and generate the response.
  • Magento\Framework\View\Element\Template: A base class for view templates that provides methods for rendering HTML and accessing the request data and other context information.