Skip to content

Instantly share code, notes, and snippets.

@richstandbrook
Last active October 1, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richstandbrook/2007696 to your computer and use it in GitHub Desktop.
Save richstandbrook/2007696 to your computer and use it in GitHub Desktop.
:PHP :Flourish bootstrap.php
<?php
define( 'DOC_ROOT', realpath(dirname(__FILE__) . '/../') );
define( 'URL_ROOT', substr(DOC_ROOT, strlen(realpath($_SERVER['DOCUMENT_ROOT']))) . '/' );
define( 'ENV', isset($_SERVER['ENV']) ? $_SERVER['ENV'] : 'dev' );
error_reporting( E_STRICT | E_ALL );
fCore::enableErrorHandling( 'html' );
fCore::enableExceptionHandling( 'html' );
fTimestamp::setDefaultTimezone( 'Europe/London' );
// This prevents cross-site session transfer
fSession::setPath( DOC_ROOT . '/storage/session/' );
/**
* Automatically includes classes
*
* @throws Exception
*
* @param string $class Name of the class to load
* @return void
*/
function __autoload( $class ){
$dirs = glob( DOC_ROOT . '/vendor/flourish/*', GLOB_ONLYDIR );
foreach( $dirs as $dir ){
$file = "$dir/$class.php";
if( file_exists($file) ){
return require $file;
}
}
throw new Exception( "The class $class could not be loaded" );
}
class Config {
public static function get( $file ){
$f = new fFile( DOC_ROOT . "/inc/$file" );
return json_decode( $f->read() );
}
}
// $config = Config::get( 'config.json' );
// function url( $path ){
// return URL_ROOT . ( ENV == 'dev' ? 'app/' : NULL ) . $path;
// }
function url( $path ){
return URL_ROOT . $path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment