Adobe Commerce 2.3 reached end of support in September 2022.

env.php reference

The env.php file contains the following sections:

Name Description
backend Settings for the Admin area
cache_types Cache storage settings
consumers_wait_for_messages Configure how consumers process messages from the message queue
cron Enable or disable the cron jobs
crypt The encryption key for cryptographic functions
db Database connection settings
directories Magento directories mapping settings
downloadable_domains List of downloadable domains
install The installation date
lock Lock provider settings
MAGE_MODE The Magento mode
queue Message queues settings
resource Mapping of resource name to a connection
session Session storage data
x-frame-options Setting for x-frame-options
system Configuration values that cannot be edited in the Admin

backend

Configure the frontName for the Magento admin url using the backend node in env.php.

1
2
3
'backend' => [
  'frontName' => 'admin'
]

cache_types

All the Magento cache types configuration are available from this node.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'cache_types' => [
  'config' => 1,
  'layout' => 1,
  'block_html' => 1,
  'collections' => 1,
  'reflection' => 1,
  'db_ddl' => 1,
  'compiled_config' => 1,
  'eav' => 1,
  'customer_notification' => 1,
  'config_integration' => 1,
  'config_integration_api' => 1,
  'full_page' => 1,
  'config_webservice' => 1,
  'translate' => 1,
  'vertex' => 1
]

Learn more about different Cache Types.

consumers_wait_for_messages

Specify whether consumers should continue polling for messages if the number of processed messages is less than the max_messages value. The default value is 1.

1
2
3
'queue' => [
    'consumers_wait_for_messages' => 1
]

The following options are available:

  • 1—Consumers continue to process messages from the message queue until reaching the max_messages value specified in the env.php file before closing the TCP connection and terminating the consumer process. If the queue empties before reaching the max_messages value, the consumer waits for more messages to arrive.

    We recommend this setting for large merchants because a constant message flow is expected and delays in processing are undesirable.

  • 0—Consumers process available messages in the queue, close the TCP connection, and terminate. Consumers do not wait for additional messages to enter the queue, even if the number of processed messages is less than the max_messages value specified in the env.php file. This can help prevent issues with cron jobs caused by long delays in message queue processing.

    We recommend this setting for smaller merchants that do not expect a constant message flow and prefer to conserve computing resources in exchange for minor processing delays when there could be no messages for days.

cron

Enable or disable cron jobs for the Magento application. By default, cron jobs are enabled. To disable them, add the cron configuration to the env.php file and set the value to 0.

1
2
3
'cron' => [
  'enabled' => 0
]

Be careful when you disable cron jobs. When they are disabled essential processes required by the Magento application will not run.

Learn more about Crons.

crypt

Magento uses an encryption key to protect passwords and other sensitive data. This key is generated during the Magento installation process.

1
2
3
'crypt' => [
  'key' => '63d409380ccb1182bfb27c231b732f05'
]

You can learn more about it at Encryption Key.

db

All database configurations are available in this node.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'db' => [
  'table_prefix' => '',
  'connection' => [
    'default' => [
      'host' => 'localhost',
      'dbname' => 'magento_db',
      'username' => 'root',
      'password' => 'admin123',
      'model' => 'mysql4',
      'engine' => 'innodb',
      'initStatements' => 'SET NAMES utf8;',
      'active' => '1'
    ]
  ]
]

directories

Optional directory mapping options that need to be set when the web server is configured to serve Magento app from the /pub directory for improved security.

1
2
3
'directories' => [
    'document_root_is_pub' => true
]

downloadable_domains

A list of downloadable domains available in this node. Additional domains can be added, removed, or listed using CLI commands.

1
2
3
'downloadable_domains' => [
    'local.vanilla.com'
]

Learn more about Downloadable Domains commands.

install

The installation date of Magento application.

1
2
3
'install' => [
  'date' => 'Tue, 23 Apr 2019 09:31:07 +0000'
]

lock

Lock provider settings are configured using the lock node.

Learn more about the lock provider at Lock Provider Configuration.

MAGE_MODE

The Magento deploy mode can be configured in this node.

1
'MAGE_MODE' => 'developer'

Learn more about Magento Modes.

queue

Message queue related configurations are available in this node.

1
2
3
4
5
6
'queue' => [
  'topics' => [
    'customer.created' => [publisher="default-rabitmq"],
    'order.created' => [publisher="default-rabitmq"],
  ]
]

Learn more about Message queue in below link Message Queue

resource

Resource configuration settings are available in this node.

1
2
3
4
5
'resource' => [
  'default_setup' => [
    'connection' => 'default'
  ]
]

session

Magento session related configurations are stored in the session node.

1
2
3
'session' => [
  'save' => 'files'
],

Learn more about session in Session.

x-frame-options

x-frame-options header can be configured using this node.

1
'x-frame-options' => 'SAMEORIGIN'

Learn more about session in x-frame-options.

system

Magento configuration values that cannot be edited in the Admin.

1
2
3
4
5
6
7
8
'system' => [
  'default' => [
    'web' => [
      'secure' => [
          'base_url' => 'https://magento.test/'
      ]
    ]
  ]

Learn more in env-php-config-set.