Skip to content
Magento glossary

What is Magento env.php?

Short answer Magento app/etc/env.php contains environment-specific deployment configuration, including protected connection and encryption settings where configured. It works alongside shared config.php, module defaults, database settings and supported environment overrides. The deployment platform determines how values are supplied; the file is not the whole configuration system.

How it works
  1. The file returns structured deployment configuration 01
  2. Shared and environment-specific concerns are separated 02
  3. The application combines configuration from more than these files 03
  4. The deployment platform controls how values arrive 04
  5. Changes need controlled validation and recovery 05
Each step is explained below

Watch for this Committing environment secrets or sharing the whole file

How it works

From deployment inputs to effective configuration

File syntax, configuration scope, overrides and service behavior need separate checks.

  1. 01

    The file returns structured deployment configuration

    The standard app/etc/env.php is a PHP configuration file containing environment-specific sections such as database connections, cache/session services and encryption settings. A field being in the file does not by itself mean the field value is encrypted.

  2. 02

    Shared and environment-specific concerns are separated

    app/etc/config.php carries shared deployment configuration, including module information and exported shared settings. env.php holds environment-specific and sensitive deployment inputs. Review what a configuration export contains instead of assuming every setting belongs in the same file.

  3. 03

    The application combines configuration from more than these files

    Deployment files are only part of Magento's configuration system. Module defaults, database-stored system settings, scope and supported environment variables can affect effective values. A value seen in one file may not explain what the running process actually uses.

  4. 04

    The deployment platform controls how values arrive

    On-premises and Adobe Commerce Cloud deployments have different configuration workflows. Cloud tooling can generate the environment file from project variables and service relationships. A manual edit may be replaced on a later deployment or conflict with a managed setting.

  5. 05

    Changes need controlled validation and recovery

    Coordinate syntax, effective settings, service compatibility and application behavior when planning a change. Keep secrets protected and review the process serving web requests, not only a CLI check. A valid PHP array is not evidence that the application can reach the intended service.

When to use

Where environment configuration fits

Prepare environment inputs and changes through the approved deployment process, with secrets and recovery material protected.

  • Preparing a new environment

    Supply environment-specific endpoints and approved secret references through the deployment process. Keep test integrations separate from live services and use synthetic data where practical.

  • Changing a service connection

    A database, cache, session or queue change needs coordination with the actual service and deployment model. This glossary explains where configuration fits; it is not a recipe to switch a shared service without testing.

  • Investigating an effective-setting mismatch

    Trace the relevant scope, deployment file, database and environment overrides. Inspect authorized redacted evidence and runtime behavior. Do not print the entire environment file into a log to find one setting.

  • Planning backup or recovery

    Protect deployment configuration and encryption material alongside the recovery plan. Access control and retention must account for the secrets these artifacts can contain. A copied database alone may not be a complete application recovery set.

Common mistakes

Three configuration assumptions to check

Inspect the minimum authorized, redacted evidence needed for the setting. Avoid sharing full files or applying generic cache workarounds.

  • Committing environment secrets or sharing the whole file

    Do not place a real environment file or authentication material in a normal source repository or support message. Use the approved secret-management process and share only the minimum redacted structure needed for diagnosis.

  • Treating config.php plus env.php as all configuration

    The database, module defaults, scope and supported environment overrides can still matter. File-locked settings can also affect what Admin users can edit. Trace the effective source before declaring a value ignored or missing.

  • Applying a generic cache or PHP workaround

    A configuration symptom may come from an override, deployment generation, process cache or service mismatch. Review the relevant process and normal deployment procedure. Broad cache clearing or globally disabling OPcache is not a diagnosis.

FAQ

Magento env.php, frequently asked questions

  • Can I store env.php in source control?
    Keep real environment-specific secrets out of ordinary source control. env.php should normally be excluded and provisioned through the approved deployment/secret process. Redacted documentation or a deliberately non-sensitive template is different from committing the actual environment file.
  • What is the difference between env.php and config.php?
    config.php is the shared deployment configuration file; env.php contains environment-specific deployment settings. They are not the complete set of Magento configuration sources. Database settings, module defaults, scope and environment overrides can determine the effective result.
  • How do I rotate the DB password in env.php?
    Coordinate the database credential change and application deployment through an authorized, tested process with recovery available. Identify which services and processes use the credential, update the approved secret source and verify the intended connection without exposing it. A blind one-line edit is not a complete rotation plan.
  • Where does Adobe Commerce Cloud store env.php?
    Adobe Commerce Cloud uses its deployment tooling and environment/service configuration to generate the application's environment configuration. Follow the current Cloud guide for the exact project. Do not assume a manual edit inside a deployed instance will survive the next deployment.
  • Can env.php live outside app/etc/?
    The supported standard deployment location is app/etc/env.php. Alternative bootstrapping or file-pool behavior is not a routine relocation switch to copy from a tutorial. Use the deployment platform's documented secret/configuration mechanisms and protect access to the normal location.
  • How do I disable opcache for env.php specifically?
    Review the PHP OPcache and deployment policy for the process serving the application. Settings such as timestamp validation affect when changed PHP files are noticed. CLI and web-serving processes can differ. Do not start by disabling OPcache globally or assume a CLI action proves the web process has refreshed its configuration.
env.php audit

Planning an environment-configuration change?

Describe the setting category, deployment model and expected behavior. Do not send a real environment file, database password, encryption key or repository credential.

Kishan Savaliya Online 10 AM to 7 PM IST Chat on WhatsApp