コード例 #1
0
ファイル: Container.php プロジェクト: Whiskey24/GoingDutchApi
 /**
  * This function registers the default services that Slim needs to work.
  *
  * All services are shared - that is, they are registered such that the
  * same instance is returned on subsequent calls.
  *
  * @param array $userSettings Associative array of application settings
  *
  * @return void
  */
 private function registerDefaultServices($userSettings)
 {
     $defaultSettings = $this->defaultSettings;
     /**
      * This service MUST return an array or an
      * instance of \ArrayAccess.
      *
      * @return array|\ArrayAccess
      */
     $this['settings'] = function () use($userSettings, $defaultSettings) {
         return new Collection(array_merge($defaultSettings, $userSettings));
     };
     $defaultProvider = new DefaultServicesProvider();
     $defaultProvider->register($this);
 }
コード例 #2
0
ファイル: container.php プロジェクト: asaokamei/slim-tuum
 * settings for Slim's Container.
 *
 * @param AppBuilder $builder
 * @return Container
 */
return function (AppBuilder $builder) {
    /** @var Container $container */
    $container = Container::forge();
    $container['notFoundHandler'] = function ($c) {
        return new NotFoundHandler($c);
    };
    $container['errorHandler'] = function ($c) {
        return new ErrorHandler($c);
    };
    $container['csrf'] = function ($c) {
        return GuardConfig::forge($c);
    };
    $container[Responder::class] = function ($c) {
        return ResponderFactory::forge($c);
    };
    $container[LoggerInterface::class] = new LoggerFactory($builder);
    $setting = ['httpVersion' => '1.1', 'responseChunkSize' => 4096, 'outputBuffering' => 'append', 'determineRouteBeforeAppMiddleware' => false, 'displayErrorDetails' => false] + $builder->get('options');
    if ($builder->debug) {
        $setting['displayErrorDetails'] = true;
    }
    $container['settings'] = $setting;
    $defaults = new DefaultServicesProvider();
    /** @noinspection PhpParamsInspection */
    $defaults->register($container);
    return $container;
};