Get Free Audit

How to Configure Magento 2 Application

Dec 1, 2016

2072 Andrey Litvin

How to Configure Magento 2 Application

At first let’s make clear what is Magento application? Magento it’s a CMS (content management system) specially designed and developed for web stores creating, in other words it’s an e-commerce platform. And Magento application it is a component of this system that processes user request and returns the final result.

Look at the following types of Magento applications that are used by web server:

  • \Magento\Framework\App\Http
  • \Magento\Framework\App\StaticResource
  • \Magento\MediaStorage\App\Media

Magento has special entry point for each application launch, and it can be used by web server.

Igor Dragun

Partner With Us

Let's discuss how to grow your business. Get a Free Quote.
Talk to Igor

Http. Index.php and pub/index.php entry point

  • It runs at http query and determines query zone (frontend, admin, soap, rest). Basically it processes queries and returns http response.

StaticResource. Pub/static.php entry point.

  • This application runs when non-existing static content is being requested (for example CSS, JavaSript and images)

It returns and generate static content to pub/static folder.

MediaResource. Pub/get.php entry point.

  • This application runs when media resources are being requested from database. It extracts media out of the database, generates static content, etc.

Let’s consider HTTP application launch example. It happens as follows:

In order of query processing:

  1. Class object of Magento\Framework\App\Bootstrap loader is created.
  2. Loader creates application type object.
  3. Loader launches application.
migration to magento 2

Magento 2 Migration

Take your online store to the next level with BelVG Magento 2 Migration

Visit the page

So it is possible to configure Magento application using the following ways:

-Using command string utility.

-If specify parameters of manual application load.

In order of loader creation you can specify some application parameters by establishing environment values $_SERVER, that is transferred into loader as a parameter.

Configurable parameters names are specified in loader class as constants.

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

BP – root dir

$_SERVER – server environment values. It is possible to specify the following parameters for loader:

Bootstrap::PARAM_REQUIRE_MAINTENANCE – default value is false

This parameter determines the way how loader processes maintenance mode. And it could have the following values:

– false (default value) – at this value, in case /var/.maintenance.flag file is exist, all ip addresses that are not listed in  /var/.maintenance.ip are blocked.

– true – in case /var/.maintenance.flag file is exist, all ip addresses that are listed in var/.maintenance.ip are blocked.

– null – maintenance check is skipped.

Bootstrap::PARAM_REQUIRE_IS_INSTALLED – checks whether Magento is installed.

Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS – paths to system directories.

You can override directories that are defined by default in getDefaultConfig() method of

 vendor/magento/framework/App/Filesystem/DirectoryList.php class

Bootstrap::INIT_PARAM_FILESYSTEM_DRIVERS – file system driver. It should have ‘\Magento\Framework\Filesystem\DriverInterface’  type.

All these parameters you can specify right before loader creating or in .htaccess file by setEnv.

– maintenance mode

Igor Dragun
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Igor


Well, let’s take a look how we can configure an application by command string utility.

Executive file is located in magento/bin directory. Let’s go to this directory and run the following commands:

  • php magento deploy:mode:show

(result :  Current application mode: developer. (Note: Environment variables may override this value.))

Example of how to enable maintenance mode using command string:

  • php magento maintenance:enable
  • php magento maintenance:enable –ip=192.0.2.10 –ip=192.0.2.11

To apply maintenance to all ip addresses, except of listed or to specified, in case  $_SERVER[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = true;

Set Magento mode (developer/production)

  • php magento deploy:mode:set developer – It sets up developer mode.

Developer mode is used for development, generates static files during every request and output information about errors exceptions.

Command string utility is a very useful tool. It can be used for managing of caching, sessions, tests launch, cron job, database updating. etc.

Here is the list of other commands:

http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands.html

magento custom development

Magento Custom Development

Take your online store to the next level with BelVG Magento Custom Development

Visit the page
Igor Dragun
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Igor

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *