Knowledgebase

Understanding Environment Configuration Print

  • phplaravel, caching, database, guide, howto, solution, zillionkinghost, hosting
  • 0

Settings that differ.

WHAT THE ENVIRONMENT FILE IS

A file of key and value pairs, read at startup, holding settings and secrets.

WHAT GOES IN IT

Database credentials Mail settings Application key Environment name and debug setting Any service credentials

WHAT NEVER GOES IN VERSION CONTROL

That file.

WHAT DOES

The example version, with placeholder values.

WHAT CONFIGURATION FILES DO

Read from the environment, providing defaults and structure.

WHAT TO READ IN YOUR CODE

Configuration, not the environment directly.

WHY

Because configuration can be cached, and cached configuration does not read the environment.

THAT POINT

Reading the environment directly outside configuration files causes values to be empty in production, mysteriously.

WHAT TO SET DIFFERENTLY IN PRODUCTION

Debug off Environment named production Appropriate log level

WHAT TO VERIFY AFTER DEPLOYMENT

That the environment file exists and is complete That it is not publicly reachable


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot