Magento's deployment configuration


Purpose of the deployment configuration

Magento’s deployment configuration consists of the module and environmental configuration for your installation. Magento’s deployment configuration is divided between:

  • <Magento base dir>/app/etc/config.php, which contains the list of installed modules, themes, and language packages
  • <Magento base dir>/app/etc/env.php, which contains environment settings, such as:

    • Database credentials and connection settings
    • Cache storage settings
    • Enabled cache types
    • Your encryption key
    • Web routing parameters (base URLs, Magento Admin URI)
    • File system paths

Together, config.php and env.php are referred to as Magento’s deployment configuration because they are created during installation and are required to start Magento.

The Magento 2 deployment configuration replaces local.xml in Magento 1.x.

Unlike other module configuration files, Magento’s deployment configuration is loaded into memory when Magento initializes, is not merged with any other files, and cannot be extended. (config.php and env.php are merged with each other, however.)

Details about the deployment configuration

config.php and env.php are PHP files that return a multi-dimensional associative array, which is basically a hierarchical arrangement of configuration parameters and values.

On the top level of this array are configuration segments. A segment has arbitrary content (a scalar value or a nested array) distinguished by an arbitrary key—where both the key and its value are defined by the Magento framework.

Magento\Framework\App\DeploymentConfig merely provides access to these sections but does not allow you to extend them.

On the next hierarchy level, items in each segment are ordered according to the module sequence definition, which is obtained by merging all modules’ configuration files, with the exception of disabled modules.

The following sections discusses the structure and contents of the deployment configuration—config.php and env.php.

Manage installed modules

config.php lists your installed components (modules, themes, and language packages). Magento provides both command-line and web-based utilities to manage components (install, uninstall, enable, disable, or upgrade).


config.php snippet:

return array (
  'modules' =>
  array (
    'Magento_Core' => 1,
    'Magento_Store' => 1,
    'Magento_Theme' => 1,
    'Magento_Authorization' => 1,
    'Magento_Directory' => 1,
    'Magento_Backend' => 1,
    'Magento_Backup' => 1,
    'Magento_Eav' => 1,
    'Magento_Customer' => 1,

The value 1 or 0 indicates whether a module is enabled or disabled.

Disabled modules are not recognized by the Magento application; in other words, they don’t participate in merging configuration, in dependency injection, events, plug-ins, and so on. Disabled modules do not modify the storefront or Admin and don’t affect routing.

The only practical difference of a module being disabled and being completely absent in the code base is that a disabled module is found by the autoloader, enabling its classes and constants to be reused in other code.

Environmental configuration

The following table provides details about each env.php segment and its structure.

Segment Key Structure
Database db
| |__/[default]
|   |-- host
|   |-- dbname
|   |-- username
|   |-- password
|   |-- model [mysql4]
|   |-- initStatements [SET NAMES utf8;]
|   |-- active [1]
|-- table_prefix
Resources resource
   |-- connection [default]
Session storage session
   |-- <files|db>
Admin URL path backend
 |-- frontName
Cache storage cache
   |__/See frontend options
Installation date install
 |-- date
Encryption key encrypt
 |-- key
Cache types cache_types
 |-- <enumerated cache types>
Message queues queue
        |-- host
        |-- port
        |-- user
        |-- password
        |-- virtualhost
        |-- ssl

Module configuration files