Default exception handling

The bootstrap object specifies how the Commerce application handles uncaught exceptions as follows:

  • In developer mode, displays the exception as-is.
  • In any other mode, attempts to log exception and display a generic error message.
  • Terminates Commerce with error code 1

Entry point applications

We have the following entry point applications (that is, applications defined by Commerce that are used by the web server as a directory index):

HTTP entry point

\Magento\Framework\App\Http operates as follows:

  1. Determines the application area.

  2. Starts the front controller and routing systems in order to find and execute a controller action.

  3. Uses an HTTP response object to return result obtained from the controller action.

  4. Error handling (in the following priority order):

    1. If you are using developer mode:

      • If the Commerce application is not installed, redirect to Setup Wizard.
      • If the Commerce application is installed, display an error and HTTP status code 500 (Internal Server Error).
    2. If the Commerce application is in maintenance mode, display a user-friendly “Service Unavailable” landing page with HTTP status code 503 (Service Unavailable).

    3. If the Commerce application is not installed, redirect to Setup Wizard.

    4. If the session is invalid, redirect to the home page.

    5. If there is any other application initialization error, display a user-friendly “Page Not Found” page with HTTP status code 404 (Not Found).

    6. On any other error, display a user-friendly “Service Unavailable” page with HTTP response 503 and generate an error report and display its ID on the page.

Static resource entry point

\Magento\Framework\App\StaticResource is an application for retrieving static resources (for example, CSS, JavaScript, and images). It postpones any actions with a static resource until the resource is requested.

INFO
The entry point for static view files is not used in production mode to avoid potential exploits on the server. In production mode, the Commerce application expects that all necessary resources exist in the <your Commerce install dir>/pub/static directory.

In default or developer mode, a request for a non-existent static resource is redirected to the static entry point according to the rewrite rules specified by the appropriate .htaccess.
When the request is redirected to the entry point, the Commerce application parses the requested URL based on retrieved parameters and finds the requested resource.

  • In developer mode, the content of the file is returned so that every time the resource is requested, the returned content is up to date.

  • In default mode, the retrieved resource is published so it is accessible by the previously requested URL.

    All future requests for the static resource are processed by the server the same as static files; that is, without involving the entry point. If it is necessary to synchronize published files with original ones, the pub/static directory should be removed; as a result, files are automatically republished with the next request.

Media resource entry point

Magento\MediaStorage\App\Media retrieves media resources (that is, any files uploaded to media storage) from the database. It is used whenever the database is configured as a media storage.

\Magento\Core\App\Media attempts to find the media file in the configured database storage and write it into the pub/static directory, then return its contents. On error, it returns an HTTP 404 (Not Found) status code in the header with no contents.

Next pageApplication modes

Commerce