Created
April 29, 2017 15:51
-
-
Save lvl99/ed62e91b550b33e1a62b4dbe2a6708f1 to your computer and use it in GitHub Desktop.
Vanilla Forums: how to support multiple configuration options depending on the server/hostname/etc.
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 | |
// Detect any specific server environment config setup to apply | |
// I use a custom variable where you can set like so in Apache VirtualHost or in .htaccess: | |
// `SetEnv HTTP_SERVER_ENVIRONMENT "staging" | |
// Default: development | |
$server_environment = 'development'; | |
if ( ! empty( $_SERVER['HTTP_SERVER_ENVIRONMENT'] ) ) { | |
$server_environment = $_SERVER['HTTP_SERVER_ENVIRONMENT']; | |
} | |
// Load the server environment config, only if a corresponding file exists | |
$env_config_path = PATH_CONF . '/config-' . $server_environment . '.php'; | |
if ( ! empty( $_SERVER['HTTP_SERVER_ENVIRONMENT'] ) && file_exists( $env_config_path ) ) { | |
Gdn::Config()->Load( $env_config_path, 'Configuration', TRUE ); | |
} |
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 if (!defined('APPLICATION')) exit(); | |
// Database | |
$Configuration['Database']['Name'] = 'example_forums_development'; | |
$Configuration['Database']['Host'] = 'localhost'; | |
$Configuration['Database']['User'] = 'root'; | |
$Configuration['Database']['Password'] = 'root'; |
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 if (!defined('APPLICATION')) exit(); | |
// Database | |
$Configuration['Database']['Name'] = 'example_forums'; | |
$Configuration['Database']['Host'] = 'mysql.example_forums.com'; | |
$Configuration['Database']['User'] = 'example_forums'; | |
$Configuration['Database']['Password'] = 'asdf1234!@#$'; |
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 if (!defined('APPLICATION')) exit(); | |
// Database | |
$Configuration['Database']['Name'] = 'example_forums_staging'; | |
$Configuration['Database']['Host'] = 'mysql.example_forums.com'; | |
$Configuration['Database']['User'] = 'example_forums'; | |
$Configuration['Database']['Password'] = 'asdf1234!@#$'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment