public function register(ContainerInterface $app) { $app->closure(PheanstalkInterface::class, function ($app) { return new Pheanstalk(config('queue.host', '127.0.0.1'), config('queue.port', Pheanstalk::DEFAULT_PORT), config('queue.timeout'), config('queue.connect_persistent', false)); }); $app->bind(SerializerInterface::class, PhpSerializer::class); $app->bind(AdapterInterface::class, BeanstalkdAdapter::class); }
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); }
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); }
/** * {@inheritdoc} */ public function register(ContainerInterface $app) { $app->closure(Manager::class, function () { $capsule = new Manager(); foreach (config('database.connections', []) as $name => $connection) { $capsule->addConnection($connection, $name); } return $capsule; }); $app->alias('database', Manager::class); $app->bind(MigrateTemplateInterface::class, MigrateTemplate::class); $app->bind(MigrateAdapterInterface::class, MigrateAdapter::class); }
/** * {@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'))); }); }
/** * {@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]); }); }
/** * {@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(); } }); }
/** * {@inheritdoc} */ public function boot(ContainerInterface $app) { date_default_timezone_set(config('timezone', 'UTC')); }
/** * {@inheritdoc} */ public function register(ContainerInterface $app) { $app->closure(RenderInterface::class, function () { return new PhpView(path(config('view.path'))); }); }
/** * {@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'))]); }); }