Skip to content

Instantly share code, notes, and snippets.

@ericatkinson
Forked from leevigraham/config_bootstrap.php
Created November 8, 2011 15:08
Show Gist options
  • Select an option

  • Save ericatkinson/1347978 to your computer and use it in GitHub Desktop.

Select an option

Save ericatkinson/1347978 to your computer and use it in GitHub Desktop.
EE config file for local, dev, stage and production environments
<?php
/**
* Custom configuration file for ExpressionEngine
*
* Place config.php in your site root
* Add require(realpath(dirname(__FILE__)."/../../config.php")); to the bottom of system/expressionengine/config/config.php
* If you have moved your site root you'll need to update the require_once path
*
* @author Leevi Graham <http://leevigraham.com>
* @link http://expressionengine.com/wiki/EE_2_Config_Overrides/
*/
// Define some environment variables
if(!defined("NSM_ENV"))
{
define("NSM_SERVER_NAME", $_SERVER['SERVER_NAME']);
define("NSM_SITE_URL", "http://".NSM_SERVER_NAME);
define("NSM_DOC_ROOT", realpath(dirname(__FILE__)));
// Set the environment
if ( strstr( NSM_SERVER_NAME, 'local' ) ) define("NSM_ENV", "local");
elseif( strstr( NSM_SERVER_NAME, 'dev' ) ) define("NSM_ENV", "dev");
elseif( strstr( NSM_SERVER_NAME, 'stage' ) ) define("NSM_ENV", "stage");
else define("NSM_ENV", "production");
}
// Placeholder arrays
$env_config = array();
$env_global_vars = array();
// Set the environmental config and global vars
if (NSM_ENV == 'local'){
$env_config = array();
$env_global_vars = array();
}
elseif(NSM_ENV == 'dev'){}
elseif(NSM_ENV == 'stage'){}
else{}
// Our default config. This shouldn't have to be changed if you're using the Newism EE2 template.
$default_config = array(
// System preferences
"is_system_on" => "y",
"admin_session_type" => "cs",
"base_url" => NSM_SITE_URL,
"cp_url" => NSM_SITE_URL . "/ee-admin/index.php",
"index_page" => "",
// Site preferences
"is_site_on" => "y",
"site_name" => "EE Template",
"site_label" => "EE Template",
"site_short_name" => "default_site",
"site_description" => "",
"site_404" => "site/four04",
"webmaster_email" => "admin@" . NSM_SERVER_NAME,
"webmaster_name" => "Admin",
// Server preferences
"server_timezone" => "UP10",
"server_offset" => FALSE,
// Channel preferences
"word_separator" => "-",
"reserved_category_word" => "cat",
// Template preferences
"strict_urls" => "y",
"save_tmpl_files" => "y",
"save_tmpl_revisions" => "y",
"tmpl_file_basepath" => NSM_DOC_ROOT . "/templates/",
// Theme preferences
"theme_folder_path" => NSM_DOC_ROOT . "/content/themes/",
"theme_folder_url" => NSM_SITE_URL . "/themes/",
// Member preferences
"allow_member_registration" => "n",
"profile_trigger" => "--sdsdjh22kj3hjksdkjhkj2lffgrerfvmdkndkfisolmfmsd",
"enable_avatars" => "n",
"avatar_path" => NSM_DOC_ROOT . "/content/uploads/member_assets/member_avatars/",
"avatar_url" => NSM_SITE_URL . "/member_assets/member_avatars/",
"avatar_max_height" => 100,
"avatar_max_width" => 100,
"avatar_max_kb" => 100,
"enable_photos" => "n",
"photo_path" => NSM_DOC_ROOT . "/content/uploads/member_assets/member_photos/",
"photo__url" => NSM_SITE_URL . "/member_assets/member_photos/",
"photo_max_height" => 200,
"photo_max_width" => 200,
"photo_max_kb" => 200,
"enable_emoticons" => "n",
"sig_allow_img_upload" => "n",
"sig_img_path" => NSM_DOC_ROOT . "/content/uploads/member_assets/signature_attachments/",
"sig_img_url" => NSM_SITE_URL . "/member_assets/signature_attachments/",
"sig_img_max_height" => 80,
"sig_img_max_width" => 480,
"sig_img_max_kb" => 30,
"sig_maxlength" => 500,
// Capcha preferences
"captcha_font" => "y",
"captcha_rand" => "y",
"captcha_require_members" => "n",
"captcha_path" => NSM_DOC_ROOT . "/content/images/captchas/",
"captcha_url" => NSM_SITE_URL . "/images/captchas/",
);
// Build the new config object
$config = array_merge($config, $default_config, $env_config);
/**
* Custom global variables
*
* This is a bit sucky as they are pulled straight from the $assign_to_config array.
* See EE_Config.php around line 90 or search for: "global $assign_to_config;"
* Output the global vars in your template with:
* <?php $EE = get_instance(); print("<pre><code>".print_r($EE->config->_global_vars, TRUE) . "</code></pre>"); ?>
* Hat tip to: Erskine from EECI2010 Preso: http://eeinsider.com/blog/eeci-2010-how-erskine-rolls-with-ee/
*/
// Make this global so we can add some of the config variables here
global $assign_to_config;
$default_global_vars = array(
// General
'gv_env' => NSM_ENV,
// Tag parameters
'gv_param_disable_default' => 'disable="categories|pagination|member_data"',
'gv_param_disable_all' => 'disable="categories|custom_fields|member_data|pagination"',
'gv_param_cache_param' => 'cache="yes" refresh="10"',
'-gv_param_cache_param' => '-cache="yes" refresh="10"', // disable by adding a "-" to the front of the global
// Date and time
'gv_date_time' => '%g:%i %a',
'gv_date_short' => '%F %d, %Y',
'gv_date_full' => '%F %d %Y, %g:%i %a'
);
$assign_to_config['global_vars'] = array_merge($default_global_vars, $env_global_vars);
<?php
/**
* Custom configuration file for ExpressionEngine
*
* Plase config_db.php in your site root
* Add require_once(realpath(dirname(__FILE__) . "/../../config_db.php")); to the bottom of system/expressionengineconfig/database.php
* If you have moved your site root you'll need to update the require_once path
*
* Configuration Options
*
* $env_db['hostname'] = "localhost";
* $env_db['username'] = "root";
* $env_db['password'] = "";
* $env_db['database'] = "EE2_template";
* $env_db['dbdriver'] = "mysql";
* $env_db['dbprefix'] = "exp_";
* $env_db['pconnect'] = FALSE;
* $env_db['swap_pre'] = "exp_";
* $env_db['db_debug'] = TRUE;
* $env_db['cache_on'] = FALSE;
* $env_db['autoinit'] = FALSE;
* $env_db['char_set'] = "utf8";
* $env_db['dbcollat'] = "utf8_general_ci";
* $env_db['cachedir'] = "/Users/leevigraham/Sites/Internal/local.ExpressionEngine2.site_template/www/system/expressionengine/cache/db_cache/";
*
* @author Leevi Graham <http://leevigraham.com>
* @link http://expressionengine.com/wiki/EE_2_Config_Overrides/
*/
// Default options
$default_db_config = array("cachedir" => APPPATH . "cache/db_cache/");
// Override the db config with environment variables
$env_db_config = array();
// Local environment
if (NSM_ENV == 'local')
$env_db_config = array(
'host_name' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'EE2_template'
);
// Development environment
elseif(NSM_ENV == 'dev')
$env_db_config = array();
// Staging environment
elseif(NSM_ENV == 'stage')
$env_db_config = array();
// Production environment
else
$env_db_config = array();
// Merge all the db config together with default options
$db['expressionengine'] = array_merge($db['expressionengine'], $default_db_config, $env_db_config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment