Dropped pickles.ph made some assumptions

Wanted to be 100% reliant on the autoloader so I dropped the manual include of
pickles.php. Also moved some of the PHP ini logic out of here and baked in
some assumptions about environments and settings. Basically anything other than
"production" will set display errors to true, production is false.
This commit is contained in:
Josh Sherman 2014-09-29 22:07:18 -04:00
parent 1c974fc9ad
commit 52c8a730f3
2 changed files with 9 additions and 45 deletions

View file

@ -38,6 +38,9 @@ class Config extends \ArrayObject
*/ */
public function __construct() public function __construct()
{ {
ini_set('display_errors', true);
error_reporting(-1);
$filename = getcwd() . '/../../pickles.php'; $filename = getcwd() . '/../../pickles.php';
$environments = false; $environments = false;
$environment = false; $environment = false;
@ -129,6 +132,12 @@ class Config extends \ArrayObject
$config['environment'] = $environment; $config['environment'] = $environment;
} }
// Disable display errors in production
if ($environment == 'production')
{
ini_set('display_errors', false);
}
// Defaults expected Pickles options to false // Defaults expected Pickles options to false
$this['pickles'] = [ $this['pickles'] = [
'cache' => false, 'cache' => false,

View file

@ -1,45 +0,0 @@
<?php
/**
* Core PICKLES Include File
*
* This is the file that you include on the page you're instantiating the
* controller from (typically index.php). The path to the PICKLES code
* base is established as well as the path that Smarty will use to store
* the compiled pages.
*
* PHP version 5
*
* Licensed under The MIT License
* Redistribution of these files must retain the above copyright notice.
*
* @author Josh Sherman <josh@gravityblvd.com>
* @copyright Copyright 2007-2014, Josh Sherman
* @license http://www.opensource.org/licenses/mit-license.html
* @package PICKLES
* @link https://github.com/joshtronic/pickles
* @usage <code>require_once 'pickles.php';</code>
*/
// Turns on error before the config is loaded to help catch parse errors
ini_set('display_errors', true);
error_reporting(-1);
// Defaults timezone to UTC if not set
if (ini_get('date.timezone') == '')
{
ini_set('date.timezone', 'Etc/UTC');
}
// Loads the base config
$config = Pickles\Config::getInstance();
// Configures any available PHP configuration options
if (isset($config['php']) && is_array($config['php']))
{
foreach ($config['php'] as $variable => $value)
{
ini_set($variable, $value);
}
}