Remmember to change paths in composer.json
Last active
July 7, 2022 20:04
-
-
Save fgilio/e43d24b1c4cdb4277fa8 to your computer and use it in GitHub Desktop.
Roots Bedrock variable webroot folder name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DB_NAME=database_name | |
DB_USER=database_user | |
DB_PASSWORD=database_password | |
DB_HOST=database_host | |
WP_ENV=development | |
WEBROOT_FOLDER_NAME=if_necessary | |
WP_HOME=http://example.com | |
WP_SITEURL=${WP_HOME}/wp | |
# Generate your keys here: https://api.wordpress.org/secret-key/1.1/salt/ | |
AUTH_KEY=generateme | |
SECURE_AUTH_KEY=generateme | |
LOGGED_IN_KEY=generateme | |
NONCE_KEY=generateme | |
AUTH_SALT=generateme | |
SECURE_AUTH_SALT=generateme | |
LOGGED_IN_SALT=generateme | |
NONCE_SALT=generateme |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$root_dir = dirname(__DIR__); | |
/** | |
* Expose global env() function from oscarotero/env | |
*/ | |
Env::init(); | |
/** | |
* Use Dotenv to set required environment variables and load .env file in root | |
*/ | |
$dotenv = new Dotenv\Dotenv($root_dir); | |
if (file_exists($root_dir . '/.env')) { | |
$dotenv->load(); | |
$dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD', 'WP_HOME', 'WP_SITEURL']); | |
} | |
/** | |
* Account for a variable webroot folder name | |
*/ | |
$webroot_folder_name = env('WEBROOT_FOLDER_NAME') ?: 'web'; | |
$webroot_dir = $root_dir .'/'. $webroot_folder_name; | |
/** | |
* Set up our global environment constant and load its config first | |
* Default: development | |
*/ | |
define('WP_ENV', env('WP_ENV') ?: 'development'); | |
$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')); | |
/** | |
* Custom Content Directory | |
*/ | |
define('CONTENT_DIR', '/app'); | |
define('WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR); | |
define('WP_CONTENT_URL', WP_HOME . 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', ''); | |
$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')); | |
/** | |
* Custom Settings | |
*/ | |
define('AUTOMATIC_UPDATER_DISABLED', true); | |
define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false); | |
define('DISALLOW_FILE_EDIT', true); | |
/** | |
* Bootstrap WordPress | |
*/ | |
if (!defined('ABSPATH')) { | |
define('ABSPATH', $webroot_dir . '/wp/'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment