Skip to content

Instantly share code, notes, and snippets.

@lleitep3
Created May 16, 2011 13:05
Show Gist options
  • Save lleitep3/974406 to your computer and use it in GitHub Desktop.
Save lleitep3/974406 to your computer and use it in GitHub Desktop.
my default bootstrap
<?php
session_start();
date_default_timezone_set ('America/Sao_Paulo');
define ('DS', DIRECTORY_SEPARATOR);
define ('URL', "http://".$_SERVER['SERVER_NAME']);
define ('ENVIRONMENT' , 'DEV');
spl_autoload_register('autoload');
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
if (ENVIRONMENT == 'DEV')
error_reporting(E_ALL);
else
error_reporting(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment