Skip to content

Instantly share code, notes, and snippets.

@keithmorris
Last active September 11, 2019 11:31
Show Gist options
  • Save keithmorris/7872642 to your computer and use it in GitHub Desktop.
Save keithmorris/7872642 to your computer and use it in GitHub Desktop.
Markdown Sandbox

Environment Aware Wordpress wp-config File

Summary

This is a customized Wordpress wp-config.php that allows loading of custom config files for specific environments. The supplemental config files follow the naming convention of wp-config-{environment}.php.

The purpose of this approach is to eliminate code changes when moving between environments (local, dev, stage, production, etc). The environments are fully customizable and based on programatically inspecting the $_SERVER['SERVER_NAME'] superglobal.

Usage

Usage is as simple as looking opening up the wp-config.php and modifying the $environments array to reflect your environments

$environments = array(
    'local'       => array('.local', 'local.example.com'),
    'development' => array('dev.example.com', 'dev.', '.dev'),
    'staging'     => 'stage.example.com',
);
@emilemarkus
Copy link

bold

#titre1

##titre2

im

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment