Пример #1
0
 public function register(ContainerInterface $app)
 {
     $app->bind(ClassLoaderInterface::class, WanduLoader::class);
     $app->bind(ResponsifierInterface::class, WanduResponsifier::class);
     $app->closure(Configuration::class, function () {
         return new Configuration(['middleware' => config('router.middleware', [Parameterify::class, Sessionify::class]), 'virtual_method_enabled' => true, 'cache_disabled' => config('router.cache_disabled', true), 'cache_file' => path(config('router.cache_file', null))]);
     });
     $app->bind(Dispatcher::class);
     $app->alias('router', Dispatcher::class);
 }
Пример #2
0
 public function register(ContainerInterface $app)
 {
     $app->closure(Logger::class, function (ContainerInterface $app) {
         $logger = new Logger('wandu');
         if ($path = config('log.path')) {
             $logger->pushHandler(new StreamHandler(Foundation\path($path)));
         }
         return $logger;
     });
     $app->alias(LoggerInterface::class, Logger::class);
     $app->alias('log', Logger::class);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function register(ContainerInterface $app)
 {
     $app->closure(Engine::class, function () {
         $engine = new Engine();
         $engine->setLoader(new FileLoader());
         $cachePath = config('view.cache');
         if ($cachePath) {
             $engine->setTempDirectory(path($cachePath));
         }
         return $engine;
     });
     $app->closure(RenderInterface::class, function ($app) {
         return new LatteView($app[Engine::class], path(config('view.path')));
     });
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function register(ContainerInterface $app)
 {
     $app->closure(Twig_Environment::class, function () {
         $loader = new Twig_Loader_Filesystem(path(config('view.path')));
         $options = [];
         $cachePath = config('view.cache');
         if ($cachePath) {
             $options['cache'] = path($cachePath);
         }
         return new Twig_Environment($loader, $options);
     });
     $app->closure(RenderInterface::class, function ($app) {
         return new TwigView($app[Twig_Environment::class]);
     });
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function register(ContainerInterface $app)
 {
     $app->closure(ResponseFactory::class, function () {
         return response();
         // singleton
     });
     $app->closure(SessionFactory::class, function ($app) {
         return new SessionFactory($app[SessionHandlerInterface::class], ['timeout' => config('session.timeout', 3600), 'name' => config('session.name', ini_get('session.name') ?: 'WdSessId'), 'gc_frequency' => config('session.gc_frequency', 100)]);
     });
     $app->closure(SessionHandlerInterface::class, function ($app) {
         switch (config('session.type')) {
             case 'file':
                 return new FileHandler(path(config('session.path', 'cache/sessions')));
             case 'redis':
                 return new RedisHandler($app[Client::class], config('session.timeout', 3600));
             default:
                 return new GlobalHandler();
         }
     });
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function register(ContainerInterface $app)
 {
     $app->closure(RenderInterface::class, function () {
         return new PhpView(path(config('view.path')));
     });
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function register(ContainerInterface $app)
 {
     $app->closure(Configuration::class, function () {
         return new Configuration(['connection' => config('database.migrator.connection'), 'table' => config('database.migrator.table'), 'path' => path(config('database.migrator.path'))]);
     });
 }