fixed changes.
This commit is contained in:
@@ -1,71 +1,71 @@
|
||||
<?php namespace Laravel;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the PHP file extension.
|
||||
// --------------------------------------------------------------
|
||||
define('EXT', '.php');
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the core framework paths.
|
||||
// --------------------------------------------------------------
|
||||
define('APP_PATH', realpath($application).'/');
|
||||
define('BASE_PATH', realpath(str_replace('laravel', '', $laravel)).'/');
|
||||
define('PACKAGE_PATH', realpath($packages).'/');
|
||||
define('PUBLIC_PATH', realpath($public).'/');
|
||||
define('STORAGE_PATH', realpath($storage).'/');
|
||||
define('SYS_PATH', realpath($laravel).'/');
|
||||
|
||||
unset($laravel, $application, $config, $packages, $public, $storage);
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define various other framework paths.
|
||||
// --------------------------------------------------------------
|
||||
define('CACHE_PATH', STORAGE_PATH.'cache/');
|
||||
define('CONFIG_PATH', APP_PATH.'config/');
|
||||
define('CONTROLLER_PATH', APP_PATH.'controllers/');
|
||||
define('DATABASE_PATH', STORAGE_PATH.'database/');
|
||||
define('LANG_PATH', APP_PATH.'language/');
|
||||
define('SESSION_PATH', STORAGE_PATH.'sessions/');
|
||||
define('SYS_CONFIG_PATH', SYS_PATH.'config/');
|
||||
define('SYS_LANG_PATH', SYS_PATH.'language/');
|
||||
define('VIEW_PATH', APP_PATH.'views/');
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Load the configuration manager and its dependencies.
|
||||
// --------------------------------------------------------------
|
||||
require SYS_PATH.'facades'.EXT;
|
||||
require SYS_PATH.'config'.EXT;
|
||||
require SYS_PATH.'arr'.EXT;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Bootstrap the IoC container.
|
||||
// --------------------------------------------------------------
|
||||
require SYS_PATH.'container'.EXT;
|
||||
|
||||
$dependencies = require SYS_CONFIG_PATH.'container'.EXT;
|
||||
|
||||
if (file_exists($path = CONFIG_PATH.'container'.EXT))
|
||||
{
|
||||
$dependencies = array_merge($dependencies, require $path);
|
||||
}
|
||||
|
||||
$env = (isset($_SERVER['LARAVEL_ENV'])) ? $_SERVER['LARAVEL_ENV'] : null;
|
||||
|
||||
if ( ! is_null($env) and file_exists($path = CONFIG_PATH.$env.'/container'.EXT))
|
||||
{
|
||||
$dependencies = array_merge($dependencies, require $path);
|
||||
}
|
||||
|
||||
$container = new Container($dependencies);
|
||||
|
||||
IoC::$container = $container;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Register the auto-loader on the auto-loader stack.
|
||||
// --------------------------------------------------------------
|
||||
spl_autoload_register(array($container->resolve('laravel.loader'), 'load'));
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Set the application environment configuration option.
|
||||
// --------------------------------------------------------------
|
||||
<?php namespace Laravel;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the PHP file extension.
|
||||
// --------------------------------------------------------------
|
||||
define('EXT', '.php');
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the core framework paths.
|
||||
// --------------------------------------------------------------
|
||||
define('APP_PATH', realpath($application).'/');
|
||||
define('BASE_PATH', realpath(str_replace('laravel', '', $laravel)).'/');
|
||||
define('PACKAGE_PATH', realpath($packages).'/');
|
||||
define('PUBLIC_PATH', realpath($public).'/');
|
||||
define('STORAGE_PATH', realpath($storage).'/');
|
||||
define('SYS_PATH', realpath($laravel).'/');
|
||||
|
||||
unset($laravel, $application, $config, $packages, $public, $storage);
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define various other framework paths.
|
||||
// --------------------------------------------------------------
|
||||
define('CACHE_PATH', STORAGE_PATH.'cache/');
|
||||
define('CONFIG_PATH', APP_PATH.'config/');
|
||||
define('CONTROLLER_PATH', APP_PATH.'controllers/');
|
||||
define('DATABASE_PATH', STORAGE_PATH.'database/');
|
||||
define('LANG_PATH', APP_PATH.'language/');
|
||||
define('SESSION_PATH', STORAGE_PATH.'sessions/');
|
||||
define('SYS_CONFIG_PATH', SYS_PATH.'config/');
|
||||
define('SYS_LANG_PATH', SYS_PATH.'language/');
|
||||
define('VIEW_PATH', APP_PATH.'views/');
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Load the configuration manager and its dependencies.
|
||||
// --------------------------------------------------------------
|
||||
require SYS_PATH.'facades'.EXT;
|
||||
require SYS_PATH.'config'.EXT;
|
||||
require SYS_PATH.'arr'.EXT;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Bootstrap the IoC container.
|
||||
// --------------------------------------------------------------
|
||||
require SYS_PATH.'container'.EXT;
|
||||
|
||||
$dependencies = require SYS_CONFIG_PATH.'container'.EXT;
|
||||
|
||||
if (file_exists($path = CONFIG_PATH.'container'.EXT))
|
||||
{
|
||||
$dependencies = array_merge($dependencies, require $path);
|
||||
}
|
||||
|
||||
$env = (isset($_SERVER['LARAVEL_ENV'])) ? $_SERVER['LARAVEL_ENV'] : null;
|
||||
|
||||
if ( ! is_null($env) and file_exists($path = CONFIG_PATH.$env.'/container'.EXT))
|
||||
{
|
||||
$dependencies = array_merge($dependencies, require $path);
|
||||
}
|
||||
|
||||
$container = new Container($dependencies);
|
||||
|
||||
IoC::$container = $container;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Register the auto-loader on the auto-loader stack.
|
||||
// --------------------------------------------------------------
|
||||
spl_autoload_register(array($container->resolve('laravel.loader'), 'load'));
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Set the application environment configuration option.
|
||||
// --------------------------------------------------------------
|
||||
$container->resolve('laravel.config')->set('application.env', $env);
|
||||
@@ -1,100 +1,189 @@
|
||||
<?php namespace Laravel;
|
||||
|
||||
class Config {
|
||||
|
||||
/**
|
||||
* All of the loaded configuration items.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = array();
|
||||
|
||||
/**
|
||||
* Create a new configuration manager instance.
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a configuration item or file exists.
|
||||
*
|
||||
* <code>
|
||||
* // Determine if the "options" configuration file exists
|
||||
* $options = Config::has('options');
|
||||
*
|
||||
* // Determine if a specific configuration item exists
|
||||
* $timezone = Config::has('application.timezone');
|
||||
* </code>
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return ! is_null($this->get($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration item.
|
||||
*
|
||||
* Configuration items are stored in the application/config directory, and provide
|
||||
* general configuration options for a wide range of Laravel facilities.
|
||||
*
|
||||
* The arrays may be accessed using JavaScript style "dot" notation to drill deep
|
||||
* intot he configuration files. For example, asking for "database.connectors.sqlite"
|
||||
* would return the connector closure for SQLite stored in the database configuration
|
||||
* file. If no specific item is specfied, the entire configuration array is returned.
|
||||
*
|
||||
* Like most Laravel "get" functions, a default value may be provided, and it will
|
||||
* be returned if the requested file or item doesn't exist.
|
||||
*
|
||||
* <code>
|
||||
* // Get the "timezone" option from the application config file
|
||||
* $timezone = Config::get('application.timezone');
|
||||
*
|
||||
* // Get an option, but return a default value if it doesn't exist
|
||||
* $value = Config::get('some.option', 'Default');
|
||||
* </code>
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $default
|
||||
* @return array
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return Arr::get($this->items, $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a configuration item.
|
||||
*
|
||||
* Configuration items are stored in the application/config directory, and provide
|
||||
* general configuration options for a wide range of Laravel facilities.
|
||||
*
|
||||
* Like the "get" method, this method uses JavaScript style "dot" notation to access
|
||||
* and manipulate the arrays in the configuration files. Also, like the "get" method,
|
||||
* if no specific item is specified, the entire configuration array will be set.
|
||||
*
|
||||
* <code>
|
||||
* // Set the "timezone" option in the "application" array
|
||||
* Config::set('application.timezone', 'America/Chicago');
|
||||
*
|
||||
* // Set the entire "session" configuration array
|
||||
* Config::set('session', $array);
|
||||
* </code>
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
Arr::set($this->items, $key, $value);
|
||||
}
|
||||
|
||||
<?php namespace Laravel;
|
||||
|
||||
class Config {
|
||||
|
||||
/**
|
||||
* All of the loaded configuration items.
|
||||
*
|
||||
* The configuration arrays are keyed by their owning file name.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $items = array();
|
||||
|
||||
/**
|
||||
* The paths to the configuration files.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
* Create a new configuration manager instance.
|
||||
*
|
||||
* @param array $paths
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($paths)
|
||||
{
|
||||
$this->paths = $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a configuration item or file exists.
|
||||
*
|
||||
* <code>
|
||||
* // Determine if the "options" configuration file exists
|
||||
* $options = Config::has('options');
|
||||
*
|
||||
* // Determine if a specific configuration item exists
|
||||
* $timezone = Config::has('application.timezone');
|
||||
* </code>
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return ! is_null($this->get($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration item.
|
||||
*
|
||||
* Configuration items are stored in the application/config directory, and provide
|
||||
* general configuration options for a wide range of Laravel facilities.
|
||||
*
|
||||
* The arrays may be accessed using JavaScript style "dot" notation to drill deep
|
||||
* intot he configuration files. For example, asking for "database.connectors.sqlite"
|
||||
* would return the connector closure for SQLite stored in the database configuration
|
||||
* file. If no specific item is specfied, the entire configuration array is returned.
|
||||
*
|
||||
* Like most Laravel "get" functions, a default value may be provided, and it will
|
||||
* be returned if the requested file or item doesn't exist.
|
||||
*
|
||||
* <code>
|
||||
* // Get the "timezone" option from the application config file
|
||||
* $timezone = Config::get('application.timezone');
|
||||
*
|
||||
* // Get an option, but return a default value if it doesn't exist
|
||||
* $value = Config::get('some.option', 'Default');
|
||||
* </code>
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $default
|
||||
* @return array
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
list($file, $key) = $this->parse($key);
|
||||
|
||||
if ( ! $this->load($file))
|
||||
{
|
||||
return ($default instanceof \Closure) ? call_user_func($default) : $default;
|
||||
}
|
||||
|
||||
if (is_null($key))
|
||||
{
|
||||
return $this->items[$file];
|
||||
}
|
||||
|
||||
return Arr::get($this->items[$file], $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a configuration item.
|
||||
*
|
||||
* Configuration items are stored in the application/config directory, and provide
|
||||
* general configuration options for a wide range of Laravel facilities.
|
||||
*
|
||||
* Like the "get" method, this method uses JavaScript style "dot" notation to access
|
||||
* and manipulate the arrays in the configuration files. Also, like the "get" method,
|
||||
* if no specific item is specified, the entire configuration array will be set.
|
||||
*
|
||||
* <code>
|
||||
* // Set the "timezone" option in the "application" array
|
||||
* Config::set('application.timezone', 'America/Chicago');
|
||||
*
|
||||
* // Set the entire "session" configuration array
|
||||
* Config::set('session', $array);
|
||||
* </code>
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
list($file, $key) = $this->parse($key);
|
||||
|
||||
$this->load($file);
|
||||
|
||||
if (is_null($key))
|
||||
{
|
||||
Arr::set($this->items, $file, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Arr::set($this->items[$file], $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a configuration key and return its file and key segments.
|
||||
*
|
||||
* Configuration keys follow a {file}.{key} convention. So, for example, the
|
||||
* "session.driver" option refers to the "driver" option within the "session"
|
||||
* configuration file.
|
||||
*
|
||||
* If no specific item is specified, such as when requested "session", null will
|
||||
* be returned as the value of the key since the entire file is being requested.
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
protected function parse($key)
|
||||
{
|
||||
$segments = explode('.', $key);
|
||||
|
||||
$key = (count($segments) > 1) ? implode('.', array_slice($segments, 1)) : null;
|
||||
|
||||
return array($segments[0], $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all of the configuration items from a module configuration file.
|
||||
*
|
||||
* If the configuration file has already been loaded into the items array, there
|
||||
* is no need to load it again, so "true" will be returned immediately.
|
||||
*
|
||||
* Configuration files cascade across directories. So, for example, if a configuration
|
||||
* file is in the system directory, its options will be overriden by a matching file
|
||||
* in the application directory.
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
protected function load($file)
|
||||
{
|
||||
if (isset($this->items[$file])) return true;
|
||||
|
||||
$config = array();
|
||||
|
||||
foreach ($this->paths as $directory)
|
||||
{
|
||||
if (file_exists($path = $directory.$file.EXT))
|
||||
{
|
||||
$config = array_merge($config, require $path);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($config) > 0)
|
||||
{
|
||||
$this->items[$file] = $config;
|
||||
}
|
||||
|
||||
return isset($this->items[$file]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,349 +1,349 @@
|
||||
<?php namespace Laravel;
|
||||
|
||||
return array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.asset' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Asset($container->resolve('laravel.html'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.auth' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Security\Auth($container->resolve('laravel.config'), $container->resolve('laravel.session'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.config' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
$paths = array(SYS_CONFIG_PATH, CONFIG_PATH);
|
||||
|
||||
if (isset($_SERVER['LARAVEL_ENV']))
|
||||
{
|
||||
$paths[] = CONFIG_PATH.$_SERVER['LARAVEL_ENV'].'/';
|
||||
}
|
||||
|
||||
return new Config($paths);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.crypter' => array('resolver' => function($container)
|
||||
{
|
||||
$key = $container->resolve('laravel.config')->get('application.key');
|
||||
|
||||
return new Security\Crypter(MCRYPT_RIJNDAEL_256, 'cbc', $key);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.cookie' => array('singleton' => true, 'resolver' => function()
|
||||
{
|
||||
return new Cookie($_COOKIE);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.database' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Database\Manager($container->resolve('laravel.config')->get('database'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.download' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Download($container->resolve('laravel.file'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.file' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new File($container->resolve('laravel.config')->get('mimes'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.form' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
list($request, $html, $url) = array(
|
||||
$container->resolve('laravel.request'),
|
||||
$container->resolve('laravel.html'),
|
||||
$container->resolve('laravel.url'),
|
||||
);
|
||||
|
||||
return new Form($request, $html, $url);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.hasher' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Security\Hashing\Bcrypt(8);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.html' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new HTML($container->resolve('laravel.url'), $container->resolve('laravel.config')->get('application.encoding'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.input' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
$request = $container->resolve('laravel.request');
|
||||
|
||||
$input = array();
|
||||
|
||||
if ($request->method() == 'GET')
|
||||
{
|
||||
$input = $_GET;
|
||||
}
|
||||
elseif ($request->method() == 'POST')
|
||||
{
|
||||
$input = $_POST;
|
||||
}
|
||||
elseif ($request->method() == 'PUT' or $request->method == 'DELETE')
|
||||
{
|
||||
($request->spoofed()) ? $input = $_POST : parse_str(file_get_contents('php://input'), $input);
|
||||
}
|
||||
|
||||
unset($input['_REQUEST_METHOD_']);
|
||||
|
||||
return new Input($container->resolve('laravel.file'), $container->resolve('laravel.cookie'), $input, $_FILES);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.lang' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'lang'.EXT;
|
||||
|
||||
return new Lang_Factory($container->resolve('laravel.config'), array(SYS_LANG_PATH, LANG_PATH));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.loader' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'loader'.EXT;
|
||||
|
||||
$aliases = $container->resolve('laravel.config')->get('aliases');
|
||||
|
||||
return new Loader(array(BASE_PATH, APP_PATH.'models/', APP_PATH.'libraries/'), $aliases);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.package' => array('singleton' => true, 'resolver' => function()
|
||||
{
|
||||
return new Package(PACKAGE_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.redirect' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Redirect($container->resolve('laravel.url'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.request' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Request($_SERVER, $_POST, $container->resolve('laravel.config')->get('application.url'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.response' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'response'.EXT;
|
||||
|
||||
return new Response_Factory($container->resolve('laravel.view'), $container->resolve('laravel.file'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.routing.router' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Routing\Router(require APP_PATH.'routes'.EXT, CONTROLLER_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.routing.caller' => array('resolver' => function($container)
|
||||
{
|
||||
return new Routing\Caller($container, require APP_PATH.'filters'.EXT, CONTROLLER_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.manager' => array('singleton' => true, 'resolver' => function($c)
|
||||
{
|
||||
$config = $c->resolve('laravel.config');
|
||||
|
||||
$driver = $c->resolve('laravel.session.'.$config->get('session.driver'));
|
||||
|
||||
return new Session\Manager($driver, $c->resolve('laravel.session.transporter'), $config);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.transporter' => array('resolver' => function($c)
|
||||
{
|
||||
return new Session\Transporters\Cookie($c->resolve('laravel.cookie'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.url' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
list($request, $base, $index) = array(
|
||||
$container->resolve('laravel.request'),
|
||||
$container->resolve('laravel.config')->get('application.url'),
|
||||
$container->resolve('laravel.config')->get('application.index'),
|
||||
);
|
||||
|
||||
return new URL($container->resolve('laravel.routing.router'), $base, $index, $request->secure());
|
||||
}),
|
||||
|
||||
|
||||
'laravel.validator' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'validation/validator'.EXT;
|
||||
|
||||
return new Validation\Validator_Factory($container->resolve('laravel.lang'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.view' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'view'.EXT;
|
||||
|
||||
return new View_Factory($container->resolve('laravel.view.composer'), VIEW_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.view.composer' => array('resolver' => function($container)
|
||||
{
|
||||
return new View_Composer(require APP_PATH.'composers'.EXT);
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Cookie Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.session.cookie' => array('resolver' => function($container)
|
||||
{
|
||||
$cookies = $container->resolve('laravel.cookie');
|
||||
|
||||
$config = $container->resolve('laravel.config')->get('session');
|
||||
|
||||
return new Session\Drivers\Cookie($container->resolve('laravel.crypter'), $cookies);
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Database Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.session.database' => array('resolver' => function($container)
|
||||
{
|
||||
$table = $container->resolve('laravel.config')->get('session.table');
|
||||
|
||||
return new Session\Drivers\Database($container->resolve('laravel.database')->connection());
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Cache Manager
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Cache\Manager($container, $container->resolve('laravel.config')->get('cache.driver'));
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel File Cache & Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache.file' => array('resolver' => function($container)
|
||||
{
|
||||
return new Cache\Drivers\File($container->resolve('laravel.file'), CACHE_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.file' => array('resolver' => function($container)
|
||||
{
|
||||
return new Session\Drivers\File($container->resolve('laravel.file'), SESSION_PATH);
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel APC Cache & Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache.apc' => array('resolver' => function($container)
|
||||
{
|
||||
return new Cache\Drivers\APC(new Proxy, $container->resolve('laravel.config')->get('cache.key'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.id' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return $container->resolve('laravel.cookie')->get('laravel_session');
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.apc' => array('resolver' => function($container)
|
||||
{
|
||||
$lifetime = $container->resolve('laravel.config')->get('session.lifetime');
|
||||
|
||||
return new Session\Drivers\APC($container->resolve('laravel.cache.apc'));
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Memcached Cache & Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache.memcached' => array('resolver' => function($container)
|
||||
{
|
||||
$connection = $container->resolve('laravel.cache.memcache.connection');
|
||||
|
||||
$key = $container->resolve('laravel.config')->get('cache.key');
|
||||
|
||||
return new Cache\Drivers\Memcached($connection, $key);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.memcached' => array('resolver' => function($container)
|
||||
{
|
||||
$lifetime = $container->resolve('laravel.config')->get('session.lifetime');
|
||||
|
||||
return new Session\Drivers\Memcached($container->resolve('laravel.cache.memcached'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.cache.memcache.connection' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
if ( ! class_exists('Memcache'))
|
||||
{
|
||||
throw new \Exception('Attempting to use Memcached, but the Memcache PHP extension is not installed on this server.');
|
||||
}
|
||||
|
||||
$memcache = new \Memcache;
|
||||
|
||||
foreach ($container->resolve('laravel.config')->get('cache.servers') as $server)
|
||||
{
|
||||
$memcache->addServer($server['host'], $server['port'], true, $server['weight']);
|
||||
}
|
||||
|
||||
if ($memcache->getVersion() === false)
|
||||
{
|
||||
throw new \Exception('Memcached is configured. However, no connections could be made. Please verify your memcached configuration.');
|
||||
}
|
||||
|
||||
return $memcache;
|
||||
}),
|
||||
|
||||
<?php namespace Laravel;
|
||||
|
||||
return array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.asset' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Asset($container->resolve('laravel.html'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.auth' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Security\Auth($container->resolve('laravel.config'), $container->resolve('laravel.session'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.config' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
$paths = array(SYS_CONFIG_PATH, CONFIG_PATH);
|
||||
|
||||
if (isset($_SERVER['LARAVEL_ENV']))
|
||||
{
|
||||
$paths[] = CONFIG_PATH.$_SERVER['LARAVEL_ENV'].'/';
|
||||
}
|
||||
|
||||
return new Config($paths);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.crypter' => array('resolver' => function($container)
|
||||
{
|
||||
$key = $container->resolve('laravel.config')->get('application.key');
|
||||
|
||||
return new Security\Crypter(MCRYPT_RIJNDAEL_256, 'cbc', $key);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.cookie' => array('singleton' => true, 'resolver' => function()
|
||||
{
|
||||
return new Cookie($_COOKIE);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.database' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Database\Manager($container->resolve('laravel.config')->get('database'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.download' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Download($container->resolve('laravel.file'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.file' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new File($container->resolve('laravel.config')->get('mimes'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.form' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
list($request, $html, $url) = array(
|
||||
$container->resolve('laravel.request'),
|
||||
$container->resolve('laravel.html'),
|
||||
$container->resolve('laravel.url'),
|
||||
);
|
||||
|
||||
return new Form($request, $html, $url);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.hasher' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Security\Hashing\Bcrypt(8);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.html' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new HTML($container->resolve('laravel.url'), $container->resolve('laravel.config')->get('application.encoding'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.input' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
$request = $container->resolve('laravel.request');
|
||||
|
||||
$input = array();
|
||||
|
||||
if ($request->method() == 'GET')
|
||||
{
|
||||
$input = $_GET;
|
||||
}
|
||||
elseif ($request->method() == 'POST')
|
||||
{
|
||||
$input = $_POST;
|
||||
}
|
||||
elseif ($request->method() == 'PUT' or $request->method == 'DELETE')
|
||||
{
|
||||
($request->spoofed()) ? $input = $_POST : parse_str(file_get_contents('php://input'), $input);
|
||||
}
|
||||
|
||||
unset($input['_REQUEST_METHOD_']);
|
||||
|
||||
return new Input($container->resolve('laravel.file'), $container->resolve('laravel.cookie'), $input, $_FILES);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.lang' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'lang'.EXT;
|
||||
|
||||
return new Lang_Factory($container->resolve('laravel.config'), array(SYS_LANG_PATH, LANG_PATH));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.loader' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'loader'.EXT;
|
||||
|
||||
$aliases = $container->resolve('laravel.config')->get('aliases');
|
||||
|
||||
return new Loader(array(BASE_PATH, APP_PATH.'models/', APP_PATH.'libraries/'), $aliases);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.package' => array('singleton' => true, 'resolver' => function()
|
||||
{
|
||||
return new Package(PACKAGE_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.redirect' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Redirect($container->resolve('laravel.url'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.request' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Request($_SERVER, $_POST, $container->resolve('laravel.config')->get('application.url'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.response' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'response'.EXT;
|
||||
|
||||
return new Response_Factory($container->resolve('laravel.view'), $container->resolve('laravel.file'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.routing.router' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Routing\Router(require APP_PATH.'routes'.EXT, CONTROLLER_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.routing.caller' => array('resolver' => function($container)
|
||||
{
|
||||
return new Routing\Caller($container, require APP_PATH.'filters'.EXT, CONTROLLER_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.manager' => array('singleton' => true, 'resolver' => function($c)
|
||||
{
|
||||
$config = $c->resolve('laravel.config');
|
||||
|
||||
$driver = $c->resolve('laravel.session.'.$config->get('session.driver'));
|
||||
|
||||
return new Session\Manager($driver, $c->resolve('laravel.session.transporter'), $config);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.transporter' => array('resolver' => function($c)
|
||||
{
|
||||
return new Session\Transporters\Cookie($c->resolve('laravel.cookie'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.url' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
list($request, $base, $index) = array(
|
||||
$container->resolve('laravel.request'),
|
||||
$container->resolve('laravel.config')->get('application.url'),
|
||||
$container->resolve('laravel.config')->get('application.index'),
|
||||
);
|
||||
|
||||
return new URL($container->resolve('laravel.routing.router'), $base, $index, $request->secure());
|
||||
}),
|
||||
|
||||
|
||||
'laravel.validator' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'validation/validator'.EXT;
|
||||
|
||||
return new Validation\Validator_Factory($container->resolve('laravel.lang'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.view' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'view'.EXT;
|
||||
|
||||
return new View_Factory($container->resolve('laravel.view.composer'), VIEW_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.view.composer' => array('resolver' => function($container)
|
||||
{
|
||||
return new View_Composer(require APP_PATH.'composers'.EXT);
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Cookie Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.session.cookie' => array('resolver' => function($container)
|
||||
{
|
||||
$cookies = $container->resolve('laravel.cookie');
|
||||
|
||||
$config = $container->resolve('laravel.config')->get('session');
|
||||
|
||||
return new Session\Drivers\Cookie($container->resolve('laravel.crypter'), $cookies);
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Database Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.session.database' => array('resolver' => function($container)
|
||||
{
|
||||
$table = $container->resolve('laravel.config')->get('session.table');
|
||||
|
||||
return new Session\Drivers\Database($container->resolve('laravel.database')->connection());
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Cache Manager
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return new Cache\Manager($container, $container->resolve('laravel.config')->get('cache.driver'));
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel File Cache & Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache.file' => array('resolver' => function($container)
|
||||
{
|
||||
return new Cache\Drivers\File($container->resolve('laravel.file'), CACHE_PATH);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.file' => array('resolver' => function($container)
|
||||
{
|
||||
return new Session\Drivers\File($container->resolve('laravel.file'), SESSION_PATH);
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel APC Cache & Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache.apc' => array('resolver' => function($container)
|
||||
{
|
||||
return new Cache\Drivers\APC(new Proxy, $container->resolve('laravel.config')->get('cache.key'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.id' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
return $container->resolve('laravel.cookie')->get('laravel_session');
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.apc' => array('resolver' => function($container)
|
||||
{
|
||||
$lifetime = $container->resolve('laravel.config')->get('session.lifetime');
|
||||
|
||||
return new Session\Drivers\APC($container->resolve('laravel.cache.apc'));
|
||||
}),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Memcached Cache & Session Components
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'laravel.cache.memcached' => array('resolver' => function($container)
|
||||
{
|
||||
$connection = $container->resolve('laravel.cache.memcache.connection');
|
||||
|
||||
$key = $container->resolve('laravel.config')->get('cache.key');
|
||||
|
||||
return new Cache\Drivers\Memcached($connection, $key);
|
||||
}),
|
||||
|
||||
|
||||
'laravel.session.memcached' => array('resolver' => function($container)
|
||||
{
|
||||
$lifetime = $container->resolve('laravel.config')->get('session.lifetime');
|
||||
|
||||
return new Session\Drivers\Memcached($container->resolve('laravel.cache.memcached'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.cache.memcache.connection' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
if ( ! class_exists('Memcache'))
|
||||
{
|
||||
throw new \Exception('Attempting to use Memcached, but the Memcache PHP extension is not installed on this server.');
|
||||
}
|
||||
|
||||
$memcache = new \Memcache;
|
||||
|
||||
foreach ($container->resolve('laravel.config')->get('cache.servers') as $server)
|
||||
{
|
||||
$memcache->addServer($server['host'], $server['port'], true, $server['weight']);
|
||||
}
|
||||
|
||||
if ($memcache->getVersion() === false)
|
||||
{
|
||||
throw new \Exception('Memcached is configured. However, no connections could be made. Please verify your memcached configuration.');
|
||||
}
|
||||
|
||||
return $memcache;
|
||||
}),
|
||||
|
||||
);
|
||||
Reference in New Issue
Block a user