Skip to content

Commit

Permalink
Merge pull request #380 from roots/class-static
Browse files Browse the repository at this point in the history
New Bedrock Configuration Model
  • Loading branch information
austinpray authored Aug 11, 2018
2 parents 0c49a3f + b4521ab commit 0042307
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 49 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"vlucas/phpdotenv": "^2.0.1",
"johnpbloch/wordpress": "4.9.8",
"oscarotero/env": "^1.1.0",
"roots/wp-password-bcrypt": "1.0.0"
"roots/wp-password-bcrypt": "1.0.0",
"roots/wp-config": "1.0.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.0.2",
Expand Down
48 changes: 45 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 50 additions & 28 deletions config/application.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<?php
/**
* Your base production configuration goes in this file. Environment-specific
* overrides go in their respective config/environments/{{WP_ENV}}.php file.
*
* A good default policy is to deviate from the production config as little as
* possible. Try to define as much of your configuration in this file as you
* can.
*/

use Roots\WPConfig\Config;

/** @var string Directory containing all of the site's files */
$root_dir = dirname(__DIR__);
Expand Down Expand Up @@ -26,54 +36,66 @@
*/
define('WP_ENV', env('WP_ENV') ?: 'production');

$env_config = __DIR__ . '/environments/' . WP_ENV . '.php';

if (file_exists($env_config)) {
require_once $env_config;
}

/**
* URLs
*/
define('WP_HOME', env('WP_HOME'));
define('WP_SITEURL', env('WP_SITEURL'));
Config::define('WP_HOME', env('WP_HOME'));
Config::define('WP_SITEURL', env('WP_SITEURL'));

/**
* Custom Content Directory
*/
define('CONTENT_DIR', '/app');
define('WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR);
define('WP_CONTENT_URL', WP_HOME . CONTENT_DIR);
Config::define('CONTENT_DIR', '/app');
Config::define('WP_CONTENT_DIR', $webroot_dir . Config::get('CONTENT_DIR'));
Config::define('WP_CONTENT_URL', Config::get('WP_HOME') . Config::get('CONTENT_DIR'));

/**
* DB settings
*/
define('DB_NAME', env('DB_NAME'));
define('DB_USER', env('DB_USER'));
define('DB_PASSWORD', env('DB_PASSWORD'));
define('DB_HOST', env('DB_HOST') ?: 'localhost');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');
Config::define('DB_NAME', env('DB_NAME'));
Config::define('DB_USER', env('DB_USER'));
Config::define('DB_PASSWORD', env('DB_PASSWORD'));
Config::define('DB_HOST', env('DB_HOST') ?: 'localhost');
Config::define('DB_CHARSET', 'utf8mb4');
Config::define('DB_COLLATE', '');
$table_prefix = env('DB_PREFIX') ?: 'wp_';

/**
* Authentication Unique Keys and Salts
*/
define('AUTH_KEY', env('AUTH_KEY'));
define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY'));
define('LOGGED_IN_KEY', env('LOGGED_IN_KEY'));
define('NONCE_KEY', env('NONCE_KEY'));
define('AUTH_SALT', env('AUTH_SALT'));
define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT'));
define('LOGGED_IN_SALT', env('LOGGED_IN_SALT'));
define('NONCE_SALT', env('NONCE_SALT'));
Config::define('AUTH_KEY', env('AUTH_KEY'));
Config::define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY'));
Config::define('LOGGED_IN_KEY', env('LOGGED_IN_KEY'));
Config::define('NONCE_KEY', env('NONCE_KEY'));
Config::define('AUTH_SALT', env('AUTH_SALT'));
Config::define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT'));
Config::define('LOGGED_IN_SALT', env('LOGGED_IN_SALT'));
Config::define('NONCE_SALT', env('NONCE_SALT'));

/**
* Custom Settings
*/
define('AUTOMATIC_UPDATER_DISABLED', true);
define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false);
define('DISALLOW_FILE_EDIT', true);
Config::define('AUTOMATIC_UPDATER_DISABLED', true);
Config::define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false);
// Disable the plugin and theme file editor in the admin
Config::define('DISALLOW_FILE_EDIT', true);
// Disable plugin and theme updates and installation from the admin
Config::define('DISALLOW_FILE_MODS', true);

/**
* Debugging Settings
*/
Config::define('WP_DEBUG_DISPLAY', false);
Config::define('SCRIPT_DEBUG', false);
ini_set('display_errors', 0);

$env_config = __DIR__ . '/environments/' . WP_ENV . '.php';

if (file_exists($env_config)) {
require_once $env_config;
}

Config::apply();

/**
* Bootstrap WordPress
Expand Down
18 changes: 14 additions & 4 deletions config/environments/development.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php
/** Development */
define('SAVEQUERIES', true);
define('WP_DEBUG', true);
define('SCRIPT_DEBUG', true);
/**
* Configuration overrides for WP_ENV === 'development'
*/

use Roots\WPConfig\Config;

Config::define('SAVEQUERIES', true);
Config::define('WP_DEBUG', true);
Config::define('SCRIPT_DEBUG', true);

ini_set('display_errors', 1);

// Enable plugin and theme updates and installation from the admin
Config::define('DISALLOW_FILE_MODS', false);
7 changes: 0 additions & 7 deletions config/environments/production.php

This file was deleted.

20 changes: 14 additions & 6 deletions config/environments/staging.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?php
/** Staging */
ini_set('display_errors', 0);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', false);
/** Disable all file modifications including updates and update notifications */
define('DISALLOW_FILE_MODS', true);
/**
* Configuration overrides for WP_ENV === 'staging'
*/

use Roots\WPConfig\Config;

/**
* You should try to keep staging as close to production as possible. However,
* should you need to, you can always override production configuration values
* with `Config::define`.
*
* Example: `Config::define('WP_DEBUG', true);`
* Example: `Config::define('DISALLOW_FILE_MODS', false);`
*/

0 comments on commit 0042307

Please sign in to comment.