container.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php namespace Laravel;
  2. return array(
  3. 'laravel.view.composers' => array('singleton' => true, 'resolver' => function()
  4. {
  5. return require APP_PATH.'composers'.EXT;
  6. }),
  7. 'laravel.routing.router' => array('singleton' => true, 'resolver' => function($c)
  8. {
  9. return new Routing\Router($c->core('routing.loader'), CONTROLLER_PATH);
  10. }),
  11. 'laravel.routing.loader' => array('singleton' => true, 'resolver' => function($c)
  12. {
  13. return new Routing\Loader(APP_PATH, ROUTE_PATH);
  14. }),
  15. 'laravel.routing.caller' => array('resolver' => function($c)
  16. {
  17. return new Routing\Caller($c, require APP_PATH.'filters'.EXT, CONTROLLER_PATH);
  18. }),
  19. 'laravel.database.connectors.sqlite' => array('resolver' => function($c)
  20. {
  21. return new Database\Connectors\SQLite(DATABASE_PATH);
  22. }),
  23. 'laravel.database.connectors.mysql' => array('resolver' => function($c)
  24. {
  25. return new Database\Connectors\MySQL;
  26. }),
  27. 'laravel.database.connectors.pgsql' => array('resolver' => function($c)
  28. {
  29. return new Database\Connectors\Postgres;
  30. }),
  31. 'laravel.cache.apc' => array('resolver' => function($c)
  32. {
  33. return new Cache\Drivers\APC(Config::get('cache.key'));
  34. }),
  35. 'laravel.cache.file' => array('resolver' => function($c)
  36. {
  37. return new Cache\Drivers\File(CACHE_PATH);
  38. }),
  39. 'laravel.cache.redis' => array('resolver' => function()
  40. {
  41. return new Cache\Drivers\Redis(Redis::db());
  42. }),
  43. 'laravel.cache.memcached' => array('resolver' => function($c)
  44. {
  45. return new Cache\Drivers\Memcached($c->core('cache.memcache.connection'), Config::get('cache.key'));
  46. }),
  47. 'laravel.cache.memcache.connection' => array('singleton' => true, 'resolver' => function($c)
  48. {
  49. $memcache = new \Memcache;
  50. foreach (Config::get('cache.memcached') as $server)
  51. {
  52. $memcache->addServer($server['host'], $server['port'], true, $server['weight']);
  53. }
  54. if ($memcache->getVersion() === false)
  55. {
  56. throw new \Exception('Could not establish memcached connection. Please verify your memcached configuration.');
  57. }
  58. return $memcache;
  59. }),
  60. 'laravel.session.apc' => array('resolver' => function($c)
  61. {
  62. return new Session\Drivers\APC($c->core('cache.apc'));
  63. }),
  64. 'laravel.session.cookie' => array('resolver' => function($c)
  65. {
  66. return new Session\Drivers\Cookie;
  67. }),
  68. 'laravel.session.database' => array('resolver' => function($c)
  69. {
  70. return new Session\Drivers\Database(Database\Manager::connection());
  71. }),
  72. 'laravel.session.file' => array('resolver' => function($c)
  73. {
  74. return new Session\Drivers\File(SESSION_PATH);
  75. }),
  76. 'laravel.session.redis' => array('resolver' => function($c)
  77. {
  78. return new Session\Drivers\Redis($c->core('cache.redis'));
  79. }),
  80. 'laravel.session.memcached' => array('resolver' => function($c)
  81. {
  82. return new Session\Drivers\Memcached($c->core('cache.memcached'));
  83. }),
  84. );