123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- <?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);
- }
- 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' => array('singleton' => true, 'resolver' => function($container)
- {
- return $container->resolve('laravel.session.manager')->driver($container->resolve('laravel.config')->get('session.driver'));
- }),
- 'laravel.session.manager' => array('singleton' => true, 'resolver' => function($container)
- {
- return new Session\Manager($container);
- }),
- '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.request')->input->cookies;
- $config = $container->resolve('laravel.config')->get('session');
- return new Session\Drivers\Cookie(Security\Crypter::make(), $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.manager')->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;
- }),
- );
|