The .env File

PHP dotenv loads your variables from a .env file into the PHP runtime, where your code reads them from the $_SERVER or $_ENV superglobals.

Amezmo generates a .env file for you when you create an instance, available from your webroot. It contains a set of predefined variables based on the options you chose at instance creation.

When a deployment runs, Amezmo copies the most recent .env file into the target release directory. When you update your configuration from the dashboard, Amezmo copies those changes into your current release directory right away. Amezmo does not validate the file before placing it in the root of your current release directory.

After the new variables are in your release directory, Amezmo reloads your workers with SIGHUP automatically.

Amezmo-Generated Variables

Amezmo generates these variables whenever you create a site.

Variable Description
APP_HOSTNAME The hostname of the application environment
STORAGE_DIRECTORY Path to the persistent storage directory
LOG_DIRECTORY This path can be used to persist log files across deployments
NODE_ENV Contains the application environment name
AMEZMO_ENVIRONMENT The environment name

Amezmo provides these database variables if your instance has MySQL installed.

Variable Description
DB_PORT Always 3306
DB_USERNAME Database username provided during instance creation
DB_HOST Hostname of your MySQL server
DB_PASSWORD Database password
DB_DATABASE Default database name
DB_VENDOR Always MySQL
DB_VERSION The MySQL version in major.minor.patch form

Amezmo provides these Redis variables if your instance has Redis installed.

Variable Description
REDIS_HOST The Redis server IP address or hostname
REDIS_PORT Always 6379

Environment Variable Hooks

When you update your .env configuration, Amezmo looks for these hooks:

Hook Description
.amezmo/config/before-change Runs before Amezmo places the updated file into your current release directory
.amezmo/config/after-change Runs after Amezmo copies the file to your current release directory, before your workers reload

Limits

  • Configuration hooks have a 15 second timeout.

See Also