Permalink
Browse files

Prepped files for sharing on GitHub

  • Loading branch information...
0 parents commit 9b62010898ddbd9550fe01e66c4addb03a2d5ee8 @erikreagan erikreagan committed Oct 25, 2011
Showing with 395 additions and 0 deletions.
  1. +23 −0 config/config.dev.php
  2. +45 −0 config/config.env.php
  3. +38 −0 config/config.local.php
  4. +246 −0 config/config.master.php
  5. +23 −0 config/config.prod.php
  6. +20 −0 config/config.stage.php
@@ -0,0 +1,23 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Development config overrides & db credentials
+ *
+ * Our database credentials and any environment-specific overrides
+ *
+ * @package Focus Lab Master Config
+ * @version 1.1
+ * @author Focus Lab, LLC <dev@focuslabllc.com>
+ */
+
+$env_db['hostname'] = 'localhost';
+$env_db['username'] = '';
+$env_db['password'] = '';
+$env_db['database'] = '';
+
+
+$env_config['webmaster_email'] = 'dev@domain.com';
+
+
+/* End of file config.dev.php */
+/* Location: ./config/config.dev.php */
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * Environment Declaration
+ *
+ * This switch statement sets our environment. The environment is used primarily
+ * in our custom config file setup. It is also used, however, in the front-end
+ * index.php file and the back-end admin.php file to set the debug mode
+ *
+ * @package Focus Lab Master Config
+ * @version 1.1
+ * @author Focus Lab, LLC <dev@focuslabllc.com>
+ */
+
+if ( ! defined('ENV'))
+{
+ switch ($_SERVER['HTTP_HOST']) {
+ case 'domain.com' :
+ define('ENV', 'prod');
+ define('ENV_FULL', 'Production');
+ define('ENV_DEBUG', FALSE);
+ break;
+
+ case 'staging.domain.com' :
+ define('ENV', 'stage');
+ define('ENV_FULL', 'Staging');
+ define('ENV_DEBUG', FALSE);
+ break;
+
+ case 'dev.domain.com' :
+ define('ENV', 'dev');
+ define('ENV_FULL', 'Development');
+ define('ENV_DEBUG', TRUE);
+ break;
+
+ default :
+ define('ENV', 'local');
+ define('ENV_FULL', 'Local');
+ define('ENV_DEBUG', TRUE);
+ break;
+ }
+}
+
+/* End of file config.env.php */
+/* Location: ./config/config.env.php */
@@ -0,0 +1,38 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Local config overrides & db credentials
+ *
+ * Our database credentials and any environment-specific overrides
+ * This file should be specific to each developer and not tracked in Git
+ *
+ * @package Focus Lab Master Config
+ * @version 1.1
+ * @author Focus Lab, LLC <dev@focuslabllc.com>
+ */
+
+
+// Local db
+$env_db['hostname'] = 'localhost';
+$env_db['username'] = '';
+$env_db['password'] = '';
+$env_db['database'] = '';
+
+/**
+ * Remote db - typically a shared development database
+ *
+ * Putting this below the local settings allows us to easily uncomment the
+ * lines to connect to a secondary connection, overriding the first settings
+ */
+// $env_db['hostname'] = 'domain.com';
+// $env_db['username'] = '';
+// $env_db['password'] = '';
+// $env_db['database'] = '';
+
+
+// Local testing email address
+$env_config['webmaster_email'] = 'me@domain.com';
+
+
+/* End of file config.local.php */
+/* Location: ./config/config.local.php */
@@ -0,0 +1,246 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Focus Lab, LLC Master Config
+ *
+ * This is the master config file for our ExpressionEngine sites
+ * The settings will contain database credentials and numerous "config overrides"
+ * used throughout the site. This file is used as first point of configuration
+ * but there are environment-specific files as well. The idea is that the environment
+ * config files contain config overrides that are specific to a single environment.
+ *
+ * Some config settings are used in multiple (but not all) environments. You will
+ * see the use of conditionals around the ENV constant in this file. This constant is
+ * defined in ./config/config.env.php which is required in the front-end index.php and the CP
+ * admin.php files. This means the constant is available at all times in the APP page loads.
+ *
+ * All config files are stored in the ./config/ directory and this master file is "required"
+ * in system/expressionengine/config/config.php and system/expressionengine/config/config.php
+ *
+ * require $_SERVER['DOCUMENT_ROOT'] . '/../config/config.master.php';
+ *
+ * This config setup is a combination of inspiration from Matt Weinberg and Leevi Graham
+ * @link http://eeinsider.com/articles/multi-server-setup-for-ee-2/
+ * @link http://ee-garage.com/nsm-config-bootstrap
+ *
+ * @package Focus Lab Master Config
+ * @version 1.1
+ * @author Focus Lab, LLC <dev@focuslabllc.com>
+ * @see https://github.com/focuslabllc/ee-master-config
+ */
+
+
+// Setup our initial arrays
+$env_db = $env_config = $env_global = $master_global = array();
+
+
+/**
+ * Database override magic
+ *
+ * If this equates to TRUE then we're in the database.php file
+ * We don't want these settings bothered with in our config.php file
+ */
+if (isset($db['expressionengine']))
+{
+ /**
+ * Load our environment-specific config file
+ * which contains our database credentials
+ *
+ * @see config/config.local.php
+ * @see config/config.dev.php
+ * @see config/config.stage.php
+ * @see config/config.prod.php
+ */
+ require $_SERVER['DOCUMENT_ROOT'] . '/../config/config.' . ENV . '.php';
+
+ // Dynamically set the cache path (Shouldn't this be done by default? Who moves the cache path?)
+ $env_db['cachedir'] = APPPATH . 'cache/db_cache/';
+
+ // Merge our database setting arrays
+ $db['expressionengine'] = array_merge($db['expressionengine'], $env_db);
+
+ // No need to have this variable accessible for the rest of the app
+ unset($env_db);
+}
+// End if (isset($db['expressionengine'])) {}
+
+
+
+/**
+ * Config override magic
+ *
+ * If this equates to TRUE then we're in the config.php file
+ * We don't want these settings bothered with in our database.php file
+ */
+if (isset($config))
+{
+
+ /**
+ * Dynamic path settings
+ *
+ * Make it easy to run the site in multiple environments and not have to switch up
+ * path settings in the database after each migration
+ * As inspired by Matt Weinberg: http://eeinsider.com/articles/multi-server-setup-for-ee-2/
+ */
+ $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
+ $base_url = $protocol . $_SERVER['HTTP_HOST'];
+ $base_path = $_SERVER['DOCUMENT_ROOT'];
+ $system_folder = APPPATH . '../';
+ $images_folder = 'images';
+ $images_path = $base_path . '/' . $images_folder;
+ $images_url = $base_url . '/' . $images_folder;
+
+ $env_config['index_page'] = '';
+ $env_config['site_index'] = '';
+ $env_config['base_url'] = $base_url . '/';
+ $env_config['site_url'] = $env_config['base_url'];
+ $env_config['cp_url'] = $env_config['base_url'] . '/admin.php';
+ $env_config['theme_folder_path'] = $base_path . '/themes/';
+ $env_config['theme_folder_url'] = $base_url . '/themes/';
+ $env_config['emoticon_path'] = $images_url . '/smileys/';
+ $env_config['captcha_path'] = $images_path . '/captchas/';
+ $env_config['captcha_url'] = $images_url . '/captchas/';
+ $env_config['avatar_path'] = $images_path . '/avatars/';
+ $env_config['avatar_url'] = $images_url . '/avatars/';
+ $env_config['photo_path'] = $images_path . '/member_photos/';
+ $env_config['photo_url'] = $images_url . '/member_photos/';
+ $env_config['sig_img_path'] = $images_path . '/signature_attachments/';
+ $env_config['sig_img_url'] = $images_url . '/signature_attachments/';
+ $env_config['prv_msg_upload_path'] = $images_path . '/pm_attachments/';
+
+
+
+ /**
+ * Template settings
+ *
+ * Working locally we want to reference our template files.
+ * In staging and production we do not use flat files (for ever-so-slightly better performance)
+ * This approach requires that we synchronize templates after each deployment of template changes
+ */
+ $env_config['save_tmpl_files'] = (ENV == 'prod') ? 'n' : 'y';
+ $env_config['tmpl_file_basepath'] = $base_path . '/../templates';
+ $env_config['hidden_template_indicator'] = '_';
+
+
+
+ /**
+ * Debugging settings
+ *
+ * These settings are helpful to have in one place
+ * for debugging purposes
+ */
+ $env_config['is_system_on'] = 'y';
+ $env_config['allow_extensions'] = 'y';
+ $env_config['email_debug'] = (ENV_DEBUG) ? 'y' : 'n' ;
+ // If we're not in production show the profile on the front-end but not in the CP
+ $env_config['show_profiler'] = ( ! ENV_DEBUG OR (isset($_GET['D']) && $_GET['D'] == 'cp')) ? 'n' : 'y' ;
+ // Show template debugging if we're not in production
+ $env_config['template_debugging'] = (ENV_DEBUG) ? 'y' : 'n' ;
+ /**
+ * Set debug to '2' if we're in dev mode, otherwise just '1'
+ *
+ * 0: no PHP/SQL errors shown
+ * 1: Errors shown to Super Admins
+ * 2: Errors shown to everyone
+ */
+ $env_config['debug'] = (ENV_DEBUG) ? '2' : '1' ;
+
+
+
+ /**
+ * Tracking & Performance settings
+ *
+ * These settings may impact what happens on certain page loads
+ * and turning them off could help with performance in general
+ */
+ $env_config['disable_all_tracking'] = 'y'; // If set to 'y' some of the below settings are disregarded
+ $env_config['enable_sql_caching'] = 'n';
+ $env_config['disable_tag_caching'] = 'n';
+ $env_config['enable_online_user_tracking'] = 'n';
+ $env_config['dynamic_tracking_disabling'] = '500';
+ $env_config['enable_hit_tracking'] = 'n';
+ $env_config['enable_entry_view_tracking'] = 'n';
+ $env_config['log_referrers'] = 'n';
+ $env_config['gzip_output'] = 'y';
+
+
+
+ /**
+ * 3rd Party Add-on config items as needed
+ */
+
+
+
+
+ /**
+ * Member-based settings
+ */
+ $env_config['profile_trigger'] = rand(0,time()); // randomize the member profile trigger word because we'll never need it
+
+
+
+ /**
+ * Other system settings
+ */
+ $env_config['new_version_check'] = 'n'; // no slowing my CP homepage down with this
+ $env_config['daylight_savings'] = date('I') ? 'y' : 'n'; // Autodetect DST
+ $env_config['use_category_name'] = 'y';
+ $env_config['reserved_category_word'] = 'category';
+ $env_config['word_separator'] = 'dash'; // dash|underscore
+
+
+
+
+ /**
+ * Load our environment-specific config file
+ * May contain override values from similar above settings
+ *
+ * @see config/config.local.php
+ * @see config/config.dev.php
+ * @see config/config.stage.php
+ * @see config/config.prod.php
+ */
+ require $_SERVER['DOCUMENT_ROOT'] . '/../config/config.' . ENV . '.php';
+
+
+
+
+ /**
+ * Setup our template-level global variables
+ *
+ * As inspired by NSM Bootstrap Config
+ * @see http://ee-garage.com/nsm-config-bootstrap
+ */
+ global $assign_to_config;
+ if( ! isset($assign_to_config['global_vars']))
+ {
+ $assign_to_config['global_vars'] = array();
+ }
+
+ // Start our array with environment variables. This gives us {global:env} and {global:env_full} tags for our templates.
+ $master_global = array(
+ 'global:env' => ENV,
+ 'global:env_full' => ENV_FULL
+ );
+
+
+
+ /**
+ * Merge arrays to form final datasets
+ *
+ * We've created our base config and global key->value stores
+ * We've also included the environment-specific arrays now
+ * Here we'll merge the arrays to create our final array dataset which
+ * respects "most recent data" first if any keys are duplicated
+ *
+ * This is how our environment settings are "king" over any defaults
+ */
+ $assign_to_config['global_vars'] = array_merge($assign_to_config['global_vars'], $master_global, $env_global); // global var arrays
+ $config = array_merge($config, $env_config); // config setting arrays
+
+}
+// End if (isset($config)) {}
+
+
+/* End of file config.master.php */
+/* Location: ./config/config.master.php */
@@ -0,0 +1,23 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Production config overrides & db credentials
+ *
+ * Our database credentials and any environment-specific overrides
+ *
+ * @package Focus Lab Master Config
+ * @version 1.1
+ * @author Focus Lab, LLC <dev@focuslabllc.com>
+ */
+
+$env_db['hostname'] = 'localhost';
+$env_db['username'] = '';
+$env_db['password'] = '';
+$env_db['database'] = '';
+
+// Sample global variable for Production only
+// Can be used in templates like "{global:google_analytics}"
+$env_global['global:google_analytics'] = 'UA-XXXXXXX-XX';
+
+/* End of file config.prod.php */
+/* Location: ./config/config.prod.php */
Oops, something went wrong.

0 comments on commit 9b62010

Please sign in to comment.