Skip to content

Environment File

Environment Configuration: File Naming Conventions

The Raydium Framework utilizes environment files to configure WordPress settings ensuring flexibility across various deployment contexts. These environment files, irrespective of their naming, serve to initialize and configure the framework and WordPress based on the specific needs of the environment they're deployed in. The naming convention primarily aids in organizing and identifying the appropriate configurations for different environments but doesn't impose specific content rules or hierarchy beyond their identification and use.

Their naming conventions offer a systematic approach to manage and deploy configurations across different environments efficiently.

Supported Environment File Names and Their Common Uses:

Understanding the File Names

The framework doesn't assign specific purposes or content distinctions to different .env file names beyond their identification and use in corresponding environments. The choice of file name is primarily for organizational convenience, reflecting the environment they are intended for. Here's an overview of the supported environment file names and their typical use cases:

  1. env or .env: Commonly used names for environment files, especially in production environments. They typically contain the essential configurations necessary for the application to run.

  2. .env.local or env.local: Typically used for local development settings. These files can contain overrides for database connections, debugging tools, and other developer-specific configurations. They are often excluded from version control to maintain developer-specific settings locally.

  3. .env.dev: Suggested for development environments where the focus is on continuous development, testing, and integration. Settings might include detailed logging and debugging options.

  4. .env.staging: Used in staging environments to replicate production settings closely with the potential inclusion of pre-production testing configurations.

  5. .env.prod: Tailored for production environments, focusing on security, performance, and scalability.

  6. .env.debug: This file can be used during intensive debugging sessions requiring verbose logging and error reporting.

  7. .env.secure: The naming suggests heightened security, but it's treated like any other environment file by the framework. It can be used as needed within your team's workflow.

Loading Order and Precedence

The framework searches for these files in the listed order, loading the first one it finds. This behavior allows for straightforward environment-specific configurations. The configuration files are loaded in the following sequence:

  1. env: Generic configuration file.
  2. .env: Commonly used in various environments.
  3. .env.secure: Sensitive or critical environments.
  4. .env.prod: Production-specific environments.
  5. .env.staging: Pre-production or staging environment environments.
  6. .env.dev: Development-specific configurations.
  7. .env.debug: Debugging and troubleshooting configurations.
  8. .env.local: Machine-specific local configurations.

This order ensures a flexible configuration system where more specific settings can override broader ones, supporting a range of development and production needs.

Loading Behavior:

The framework scans for these files and loads the first one it encounters. This feature allows for straightforward, environment-specific configuration management:

  • In local development, a developer could use .env.local for personal settings, overriding configurations of the production env or .env file, ensuring local customizations don't affect shared settings.

  • In production, the presence of a .env or .env.prod ensures that production-specific configurations are applied.

Recommendations and Best Practices

  • Version Control: Include generic env file in your version control system but exclude environment-specific files (like .env.local or .env.prod) to prevent sensitive or environment-specific configurations from being shared or inadvertently deployed.

  • Consistency: Maintain consistent structure and variable naming across your .env files to prevent confusion and errors when switching between environments.

  • Documentation: Clearly document the purpose and usage of each .env file within your project's documentation to ensure team members understand the workflow and file naming conventions.

By adopting a systematic approach to naming and managing environment configuration files, the Raydium Framework facilitates a smooth and efficient development-to-deployment workflow, accommodating the diverse needs of different environments without complicating the overall configuration process.