Files
spa-api/laravel/bootstrap/core.php

76 lines
1.8 KiB
PHP
Raw Normal View History

2011-09-19 21:33:25 -05:00
<?php namespace Laravel;
require 'constants.php';
/**
2011-09-29 21:22:48 -05:00
* Load the classes that can't be resolved through the auto-loader.
* These are typically classes that are used by the auto-loader or
* configuration classes, and therefore cannot be auto-loaded.
*/
require SYS_PATH.'arr'.EXT;
2011-09-19 21:33:25 -05:00
require SYS_PATH.'config'.EXT;
2011-10-07 16:05:48 -05:00
/**
* Load some core configuration files by default so we don't have to
* let them fall through the Config parser. This will allow us to
2011-10-07 16:05:48 -05:00
* load these files faster for each request.
*/
Config::load('application');
Config::load('container');
Config::load('session');
2011-10-10 21:34:15 -05:00
/**
2011-09-29 21:22:48 -05:00
* Bootstrap the application inversion of control (IoC) container.
* The container provides the convenient resolution of objects and
* their dependencies, allowing for flexibility and testability
* within the framework and application.
*/
require SYS_PATH.'container'.EXT;
2011-09-19 21:33:25 -05:00
2011-10-10 21:34:15 -05:00
$container = new Container(Config::$items['container']);
2011-09-19 21:33:25 -05:00
IoC::$container = $container;
unset($container);
2011-10-10 22:17:22 -05:00
/**
* Register the application auto-loader. The auto-loader closure
* is responsible for the lazy-loading of all of the Laravel core
* classes, as well as the developer created libraries and models.
*/
$aliases = Config::$items['application']['aliases'];
2011-10-05 18:32:48 -05:00
spl_autoload_register(function($class) use ($aliases)
{
if (array_key_exists($class, $aliases))
{
return class_alias($aliases[$class], $class);
}
$file = strtolower(str_replace('\\', '/', $class));
foreach (array(BASE_PATH, MODEL_PATH, LIBRARY_PATH) as $path)
{
if (file_exists($path = $path.$file.EXT))
{
require_once $path;
return;
}
}
});
unset($aliases);
2011-09-20 21:28:19 -05:00
/**
* Define a few convenient global functions.
*/
2011-10-08 22:41:52 -05:00
function e($value)
{
return HTML::entities($value);
}
function __($key, $replacements = array(), $language = null)
{
return Lang::line($key, $replacements, $language);
}