Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom configuration file for ExpressionEngine 2
<?php
/**************************************************
Custom configuration bootstrap file for ExpressionEngine
1) Place config.php above site root
2) Require this bootstrap file at the bottom of the config and database files:
system/expressionengine/config/config.php
Example: require(realpath(dirname(__FILE__) . '/../../../config.php'));
system/expressionengine/config/database.php
Example: require(realpath(dirname(__FILE__) . '/../../../config.php'));
3) Since file upload paths can't be managed here, make sure they are relative paths in the Control Panel
@link http://getbunch.com/post/5502651876/how-to-configure-expressionengine-for-multiple-server
Server Path: ../public_html/uploads/pdf_downloads/
URL: /public_html/uploads/pdf_downloads/
Inspiration & props:
@link http://ee-garage.com/nsm-config-bootstrap
@link http://eeinsider.com/blog/eeci-2010-how-erskine-rolls-with-ee
@link http://eeinsider.com/articles/multi-server-setup-for-ee-2
Resources
@link http://expressionengine.com/wiki/EE_2_Config_Overrides
Attribution
@author Ben Parizek - http://benparizek.com
Principal/Creative Director - (Barrel Strength) Design - http://barrelstrengthdesign.com
while now significantly modified, largely inspired by this gist (https://gist.github.com/464756)
@author Leevi Graham <http://leevigraham.com>, Technical Director - Newism <http://newism.com.au>
***************************************************/
/**************************************************
SETUP THE ENVIRONMENT
***************************************************/
if(!defined('THIS_ENV')) {
define('THIS_SERVER_NAME', $_SERVER['SERVER_NAME']);
define('THIS_SITE_URL', 'http://' . THIS_SERVER_NAME);
define('THIS_SITE_URL_SSL', 'https://' . THIS_SERVER_NAME);
define('THIS_SITE_URL_SSL_SWAP', ($_SERVER['HTTPS'] == 'on' ? THIS_SITE_URL_SSL : THIS_SITE_URL));
define('THIS_BASEPATH', dirname(__FILE__));
define('THIS_SYSTEM_FOLDER', 'ee-framework');
// Set the environment
if ( strstr( THIS_SERVER_NAME, 'local.' )) define('THIS_ENV', 'local');
elseif ( strstr( THIS_SERVER_NAME, 'dev.' )) define('THIS_ENV', 'dev');
elseif ( strstr( THIS_SERVER_NAME, 'staging.' )) define('THIS_ENV', 'staging');
else define('THIS_ENV', 'live');
}
/**************************************************
SET THE ENVIRONMENTAL CONFIG VALUES
SET THE ENVIRONMENTAL GLOBAL VARIABLES
We will set the ENVIRONMENTAL DATABASE later
***************************************************/
if (THIS_ENV == 'local') {
$db_hostname = 'localhost';
$db_username = 'root';
$db_password = 'root';
$db_database = 'ee_customize_demo';
// Don't use https:// in local environment
$env_global_vars['global:site_url_ssl'] = THIS_SITE_URL . '/';
$env_global_vars['global:site_url_ssl_swap'] = THIS_SITE_URL . '/';
//$config[''] = '';
//$assign_to_config['global_vars']['google_analytics_key'] = '';
//$assign_to_config['global_vars']['global:cm_subscriber_list_slug'] = '';
}
elseif(THIS_ENV == 'dev') {
$db_hostname = '';
$db_username = '';
$db_password = '';
$db_database = '';
// Don't use https:// in dev environment
$env_global_vars['global:site_url_ssl'] = THIS_SITE_URL . '/';
$env_global_vars['global:site_url_ssl_swap'] = THIS_SITE_URL . '/';
//$assign_to_config['global_vars']['google_analytics_key'] = '';
}
elseif(THIS_ENV == 'live') {
$db_hostname = '';
$db_username = '';
$db_password = '';
$db_database = '';
// Use https:// in live environment
$env_global_vars['global:site_url_ssl'] = THIS_SITE_URL_SSL . '/';
$env_global_vars['global:site_url_ssl_swap'] = THIS_SITE_URL_SSL_SWAP . '/';
//$assign_to_config['global_vars']['google_analytics_key'] = 'XX-XXXX';
//$assign_to_config['global_vars']['tmpl_file_basepath'] = THIS_BASEPATH . '/templates_mobile/';
}
else {
die('No Environment Found. Environmental CONFIG & GLOBAL VARIABLES not setup properly. See bootstrap_config file.');
}
/**************************************************
SET DEFAULT CONFIG VALUES
Check to make sure we have processed the default EE config.php
If we have, set as many config values as we can in this file.
***************************************************/
if(isset($config)) {
// calculate value for daylight savings dynamically to use in $default_config array.
date_default_timezone_set('America/Los_Angeles');
$daylight_savings_status = (date("I") == 1) ? 'y' : 'n';
// General preferences
$config['is_system_on'] = 'y';
$config['license_number'] = '';
$config['site_index'] = '';
$config['admin_session_type'] = 'cs';
$config['new_version_check'] = 'y';
$config['doc_url'] = 'http://expressionengine.com/user_guide/';
$config['site_url'] = THIS_SITE_URL . '/'; // needs trailing slash for CP link to work
$config['cp_url'] = THIS_SITE_URL . '/ee-admin.php'; // system folder below web root
$config['cp_theme'] = 'nerdery';
// Set this so we can use query strings
$config['uri_protocol'] = 'PATH_INFO';
// Database preferences
$config['db_debug'] = 'n';
$config['pconnect'] = 'n';
$config['enable_db_caching'] = 'n';
// Site preferences. May need to be set in index.php for MSM sites.
$config['is_site_on'] = 'y';
$config['site_404'] = 'system-messages/page-not-found/';
$config['webmaster_email'] = 'webmaster@' . THIS_SERVER_NAME;
$config['webmaster_name'] = 'Webmaster';
// Localization preferences
$config['server_timezone'] = 'UM8'; // Pacific Standard Time
$config['server_offset'] = FALSE;
$config['time_format'] = 'us';
$config['daylight_savings'] = $daylight_savings_status; // value calculated dynamically above
$config['honor_entry_dst'] = 'y';
// Channel preferences
$config['use_category_name'] = 'y';
$config['word_separator'] = 'dash';
$config['reserved_category_word'] = 'category';
// Template preferences
$config['strict_urls'] = 'y';
$config['save_tmpl_files'] = 'y';
$config['save_tmpl_revisions'] = 'y';
$config['tmpl_file_basepath'] = THIS_BASEPATH . '/public_html/templates/';
// Theme preferences
$config['theme_folder_path'] = THIS_BASEPATH . '/public_html/themes/';
$config['theme_folder_url'] = THIS_SITE_URL . '/themes/';
// Tracking preferences
$config['enable_online_user_tracking'] = 'n';
$config['dynamic_tracking_disabling'] = '500';
$config['enable_hit_tracking'] = 'n';
$config['enable_entry_view_tracking'] = 'n';
$config['log_referrers'] = 'n';
// Member preferences
$config['allow_registration'] = 'n';
$config['profile_trigger'] = '--abjhkj2lfdarerfvmdkndkfidolmfmkd' . time();
$config['prv_msg_upload_path'] = THIS_BASEPATH . '/public_html/content/members/pm_attachments';
$config['enable_emoticons'] = 'n';
$config['enable_avatars'] = 'n';
$config['avatar_path'] = THIS_BASEPATH . '/public_html/content/members/avatars/';
$config['avatar_url'] = THIS_SITE_URL . '/content/members/avatars/';
$config['avatar_max_height'] = '100';
$config['avatar_max_width'] = '100';
$config['avatar_max_kb'] = '100';
$config['enable_photos'] = 'n';
$config['photo_path'] = THIS_BASEPATH . '/public_html/content/members/photos/';
$config['photo_url'] = THIS_SITE_URL . '/content/members/photos/';
$config['photo_max_height'] = '200';
$config['photo_max_width'] = '200';
$config['photo_max_kb'] = '200';
$config['sig_allow_img_upload'] = 'n';
$config['sig_img_path'] = THIS_BASEPATH . '/public_html/uploads/members/signature_attachments/';
$config['sig_img_url'] = THIS_SITE_URL . '/content/members/signature_attachments/';
$config['sig_img_max_height'] = '80';
$config['sig_img_max_width'] = '480';
$config['sig_img_max_kb'] = '30';
$config['sig_maxlength'] = '500';
$config['captcha_font'] = 'y';
$config['captcha_rand'] = 'y';
$config['captcha_require_members'] = 'n';
$config['captcha_path'] = THIS_BASEPATH . '/public_html/assets/images/captchas/';
$config['captcha_url'] = THIS_SITE_URL.'/assets/images/captchas/';
// Encryption / Session key
$config['encryption_key'] = 'Ir0nV6MSzbcPgrKNRPXT1yjjcF57VRam';
// Debugging and performance
$config['show_profiler'] = 'n'; # y/n
$config['template_debugging'] = 'n'; # y/n
$config['debug'] = '1'; # 0|1|2 off | errors->Super Admins | errors->everyone
$config['disable_all_tracking'] = 'y'; # y/n
$config['enable_sql_caching'] = 'n'; # y/n
$config['email_debug'] = 'n'; # y/n
/**************************************************
SET CUSTOM GLOBAL VARIABLES
Create some global variables that can be used throughout our website.
***************************************************/
global $assign_to_config; // Make this global so we can add some of the config variables here
// make sure our global vars config exists
if(!isset($assign_to_config['global_vars']))
$assign_to_config['global_vars'] = array();
// General - Set the production environment so we can test / show / hide components
$global_vars['global:env'] = THIS_ENV;
// Swap SSL setting based on environment
// $global_vars['global:ssl_swap'] = ($_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://');
// Tag parameters - Short hand tag params
$global_vars['global:param_disable_default'] = 'disable="categories|member_data|pagination|trackbacks"';
$global_vars['global:param_disable_all'] = 'disable="categories|custom_fields|member_data|pagination|trackbacks"';
$global_vars['global:param_cache_param'] = 'cache="yes" refresh="10"';
$global_vars['-global:param_cache_param'] = '-cache="yes" refresh="10"'; // disable by adding '-'
// Date and time - Short hand date and time
$global_vars['global:date_time'] = '%g:%i %a';
$global_vars['global:date_short'] = '%F %d, %Y';
$global_vars['global:date_full'] = '%F %d %Y, %g:%i %a';
// <form action="http://newism.createsend.com/t/y/s/{global:cm_subscriber_list_slug}/" method="post">
$global_vars['global:cm_subscriber_list_slug'] = false;
// _gaq.push(['_setAccount', 'UA-{global:google_analytics_key}']);
$global_vars['global:google_analytics_key'] = false;
// Use this variable to cache bust css and js files
// /xyz.css?cache={global:timestamp}
$global_vars['global:timestamp'] = '20111012';
// Merge environmental global variables with all global variables.
$assign_to_config['global_vars'] = array_merge($env_global_vars, $global_vars);
} // end if $config
/**************************************************
SET ENVIRONMENTAL DATABASE SETTINGS
Make sure we have reached the database.php config file
When we have, override the settings with the proper environment
***************************************************/
if(isset($db['expressionengine']))
{
$db['expressionengine']['hostname'] = $db_hostname;
$db['expressionengine']['username'] = $db_username;
$db['expressionengine']['password'] = $db_password;
$db['expressionengine']['database'] = $db_database;
// Set the database cache for the environment we are in
$db['expressionengine']['cachedir'] = APPPATH . "cache/db_cache/";
} // end if $db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.