diff --git a/application/config/.gitignore b/application/config/.gitignore new file mode 100644 index 00000000..2b706e2b --- /dev/null +++ b/application/config/.gitignore @@ -0,0 +1,2 @@ +local/* +staging/* \ No newline at end of file diff --git a/application/storage/db/.gitignore b/application/storage/db/.gitignore index e69de29b..6a91a439 100644 --- a/application/storage/db/.gitignore +++ b/application/storage/db/.gitignore @@ -0,0 +1 @@ +*.sqlite \ No newline at end of file diff --git a/public/index.php b/public/index.php index aed6bb74..30ea8a1b 100644 --- a/public/index.php +++ b/public/index.php @@ -15,8 +15,9 @@ define('BASE_PATH', realpath('../').'/'); define('APP_PATH', realpath('../application').'/'); define('SYS_PATH', realpath('../system').'/'); -define('PUBLIC_PATH', realpath(__DIR__.'/')); +define('CONFIG_PATH', APP_PATH.'config/'); define('PACKAGE_PATH', APP_PATH.'packages/'); +define('PUBLIC_PATH', realpath(__DIR__.'/')); // -------------------------------------------------------------- // Define the PHP file extension. diff --git a/system/config.php b/system/config.php index ec459195..5cc0d30f 100644 --- a/system/config.php +++ b/system/config.php @@ -95,17 +95,24 @@ class Config { /** * Load all of the configuration items from a file. * + * If it exists, the configuration file in the application/config directory will be loaded first. + * Any environment specific configuration files will be merged with the root file. + * * @param string $file * @return void */ public static function load($file) { - $directory = (isset($_SERVER['LARAVEL_ENV'])) ? $_SERVER['LARAVEL_ENV'].'/' : ''; + if (array_key_exists($file, static::$items)) return; - if ( ! array_key_exists($file, static::$items) and file_exists($path = APP_PATH.'config/'.$directory.$file.EXT)) + $config = (file_exists($path = CONFIG_PATH.$file.EXT)) ? require $path : array(); + + if (isset($_SERVER['LARAVEL_ENV']) and file_exists($path = CONFIG_PATH.$_SERVER['LARAVEL_ENV'].'/'.$file.EXT)) { - static::$items[$file] = require $path; + $config = array_merge($config, require $path); } + + return static::$items[$file] = $config; } } \ No newline at end of file