/** * Load the configuration items from all of the files. * * @param \Viserio\Contracts\Foundation\Application $app * @param \Viserio\Contracts\Config\Manager $configManager */ protected function loadConfigurationFiles(Application $app, ConfigManager $configManager) { $configPath = realpath($app->get(ConfigManager::class)->get('path.config')); foreach ($this->getFiles($configPath) as $key => $path) { $configManager->import($path); } }
/** * {@inheritdoc} */ public function bootstrap(Application $app) { $routesPath = realpath($app->get(ConfigManager::class)->get('path.routes')); foreach ($this->getFiles($routesPath) as $key => $path) { require_once $path; } }
/** * {@inheritdoc} */ public function bootstrap(Application $app) { $config = $app->get(ConfigManager::class); $providers = $config->get('app.serviceprovider', []); if (count($providers) > 0) { foreach ($providers as $provider) { $app->register($app->make($provider)); } } }
/** * Detect if a custom environment file matching the APP_ENV exists. * * @param \Viserio\Contracts\Foundation\Application $app */ protected function checkForSpecificEnvironmentFile(Application $app) { if (!getenv('APP_ENV')) { return; } $file = $app->environmentFile() . '.' . getenv('APP_ENV'); if (file_exists($app->environmentPath() . '/' . $file)) { $app->loadEnvironmentFrom($file); } }
/** * Convert request into response. * * @param \Psr\Http\Message\ServerRequestInterface $request * @param \Psr\Http\Message\ResponseInterface $response * * @return \Psr\Http\Message\ResponseInterface */ protected function handleRequest(ServerRequestInterface $request, ResponseInterface $response) { $this->bootstrap(); $router = $this->router; $config = $this->app->get(ConfigManager::class); $router->setCachePath($config->get('routing.path')); $router->refreshCache($config->get('app.env', 'production') === 'production' ? false : true); try { $response = $router->dispatch($request, $response); $this->events->trigger(self::RESPONSE, [$request, $response]); } catch (Throwable $exception) { $this->events->trigger(self::EXCEPTION, [$request, $response]); $exceptionHandler = $this->app->get(HandlerContract::class); $exceptionHandler->report($exception = new FatalThrowableError($exception)); $response = $exceptionHandler->render($request, $exception); } return $response; }
/** * {@inheritdoc} */ public function bootstrap(Application $app) { $app->register(new ExceptionServiceProvider()); $handler = $app->get(HandlerContract::class); $handler->register(); }
/** * {@inheritdoc} */ public function bootstrap(Application $app) { $app->register(new ConsoleServiceProvider()); $config = $app->get(ConfigManager::class); $loadedFromCache = false; // First we will see if we have a cache console commands file. // If we do, we'll load the console commands. if (file_exists($cached = $config->get('patch.cached.commands'))) { foreach ($cached as $command) { $app->get(ApplicationContract::class)->add($command); } $loadedFromCache = true; } if (!$loadedFromCache) { foreach ($app->getBindings() as $key => $binding) { if (preg_match('/command$/', $key)) { $app->get(ApplicationContract::class)->add($app->get($key)); } if (preg_match('/commands$/', $key) && is_array($commands = $app->get($key))) { $app->get(ApplicationContract::class)->addCommands($commands); } if (preg_match('/command.helper$/', $key)) { $app->get(ApplicationContract::class)->setHelperSet($app->get($key)); } if (preg_match('/(command.helpers|commands.helpers)$/', $key) && is_array($helpers = $app->get($key))) { foreach ($helpers as $helper) { $app->get(ApplicationContract::class)->setHelperSet($helper); } } } } }
/** * Report the exception to the exception handler. * * @param \Throwable $exception */ protected function reportException(Throwable $exception) { $this->app->get(HandlerContract::class)->report($exception); }