8889841cBootProviders.php000066600000000544150513526670010077 0ustar00boot(); } } SetRequestForConsole.php000066600000001517150513526670011375 0ustar00make('config')->get('app.url', 'http://localhost'); $components = parse_url($uri); $server = $_SERVER; if (isset($components['path'])) { $server = array_merge($server, [ 'SCRIPT_FILENAME' => $components['path'], 'SCRIPT_NAME' => $components['path'], ]); } $app->instance('request', Request::create( $uri, 'GET', [], [], [], $server )); } } LoadEnvironmentVariables.php000066600000005333150513526670012234 0ustar00configurationIsCached()) { return; } $this->checkForSpecificEnvironmentFile($app); try { $this->createDotenv($app)->safeLoad(); } catch (InvalidFileException $e) { $this->writeErrorAndDie($e); } } /** * Detect if a custom environment file matching the APP_ENV exists. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ protected function checkForSpecificEnvironmentFile($app) { if ($app->runningInConsole() && ($input = new ArgvInput)->hasParameterOption('--env')) { if ($this->setEnvironmentFilePath( $app, $app->environmentFile().'.'.$input->getParameterOption('--env') )) { return; } } $environment = Env::get('APP_ENV'); if (! $environment) { return; } $this->setEnvironmentFilePath( $app, $app->environmentFile().'.'.$environment ); } /** * Load a custom environment file. * * @param \Illuminate\Contracts\Foundation\Application $app * @param string $file * @return bool */ protected function setEnvironmentFilePath($app, $file) { if (is_file($app->environmentPath().'/'.$file)) { $app->loadEnvironmentFrom($file); return true; } return false; } /** * Create a Dotenv instance. * * @param \Illuminate\Contracts\Foundation\Application $app * @return \Dotenv\Dotenv */ protected function createDotenv($app) { return Dotenv::create( Env::getRepository(), $app->environmentPath(), $app->environmentFile() ); } /** * Write the error information to the screen and exit. * * @param \Dotenv\Exception\InvalidFileException $e * @return void */ protected function writeErrorAndDie(InvalidFileException $e) { $output = (new ConsoleOutput)->getErrorOutput(); $output->writeln('The environment file is invalid!'); $output->writeln($e->getMessage()); exit(1); } } RegisterFacades.php000066600000001333150513526670010326 0ustar00make('config')->get('app.aliases', []), $app->make(PackageManifest::class)->aliases() ))->register(); } } RegisterProviders.php000066600000000577150513526670010766 0ustar00registerConfiguredProviders(); } } LoadConfiguration.php000066600000007152150513526670010707 0ustar00getCachedConfigPath())) { $items = require $cached; $loadedFromCache = true; } // Next we will spin through all of the configuration files in the configuration // directory and load each one into the repository. This will make all of the // options available to the developer for use in various parts of this app. $app->instance('config', $config = new Repository($items)); if (! isset($loadedFromCache)) { $this->loadConfigurationFiles($app, $config); } // Finally, we will set the application's environment based on the configuration // values that were loaded. We will pass a callback which will be used to get // the environment in a web context where an "--env" switch is not present. $app->detectEnvironment(function () use ($config) { return $config->get('app.env', 'production'); }); date_default_timezone_set($config->get('app.timezone', 'UTC')); mb_internal_encoding('UTF-8'); } /** * Load the configuration items from all of the files. * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Config\Repository $repository * @return void * * @throws \Exception */ protected function loadConfigurationFiles(Application $app, RepositoryContract $repository) { $files = $this->getConfigurationFiles($app); if (! isset($files['app'])) { throw new Exception('Unable to load the "app" configuration file.'); } foreach ($files as $key => $path) { $repository->set($key, require $path); } } /** * Get all of the configuration files for the application. * * @param \Illuminate\Contracts\Foundation\Application $app * @return array */ protected function getConfigurationFiles(Application $app) { $files = []; $configPath = realpath($app->configPath()); foreach (Finder::create()->files()->name('*.php')->in($configPath) as $file) { $directory = $this->getNestedDirectory($file, $configPath); $files[$directory.basename($file->getRealPath(), '.php')] = $file->getRealPath(); } ksort($files, SORT_NATURAL); return $files; } /** * Get the configuration file nesting path. * * @param \SplFileInfo $file * @param string $configPath * @return string */ protected function getNestedDirectory(SplFileInfo $file, $configPath) { $directory = $file->getPath(); if ($nested = trim(str_replace($configPath, '', $directory), DIRECTORY_SEPARATOR)) { $nested = str_replace(DIRECTORY_SEPARATOR, '.', $nested).'.'; } return $nested; } } HandleExceptions.php000066600000014743150513526670010541 0ustar00app = $app; error_reporting(-1); set_error_handler([$this, 'handleError']); set_exception_handler([$this, 'handleException']); register_shutdown_function([$this, 'handleShutdown']); if (! $app->environment('testing')) { ini_set('display_errors', 'Off'); } } /** * Report PHP deprecations, or convert PHP errors to ErrorException instances. * * @param int $level * @param string $message * @param string $file * @param int $line * @param array $context * @return void * * @throws \ErrorException */ public function handleError($level, $message, $file = '', $line = 0, $context = []) { if ($this->isDeprecation($level)) { return $this->handleDeprecation($message, $file, $line); } if (error_reporting() & $level) { throw new ErrorException($message, 0, $level, $file, $line); } } /** * Reports a deprecation to the "deprecations" logger. * * @param string $message * @param string $file * @param int $line * @return void */ public function handleDeprecation($message, $file, $line) { if (! class_exists(LogManager::class) || ! $this->app->hasBeenBootstrapped() || $this->app->runningUnitTests() ) { return; } try { $logger = $this->app->make(LogManager::class); } catch (Exception $e) { return; } $this->ensureDeprecationLoggerIsConfigured(); with($logger->channel('deprecations'), function ($log) use ($message, $file, $line) { $log->warning(sprintf('%s in %s on line %s', $message, $file, $line )); }); } /** * Ensure the "deprecations" logger is configured. * * @return void */ protected function ensureDeprecationLoggerIsConfigured() { with($this->app['config'], function ($config) { if ($config->get('logging.channels.deprecations')) { return; } $this->ensureNullLogDriverIsConfigured(); $driver = $config->get('logging.deprecations') ?? 'null'; $config->set('logging.channels.deprecations', $config->get("logging.channels.{$driver}")); }); } /** * Ensure the "null" log driver is configured. * * @return void */ protected function ensureNullLogDriverIsConfigured() { with($this->app['config'], function ($config) { if ($config->get('logging.channels.null')) { return; } $config->set('logging.channels.null', [ 'driver' => 'monolog', 'handler' => NullHandler::class, ]); }); } /** * Handle an uncaught exception from the application. * * Note: Most exceptions can be handled via the try / catch block in * the HTTP and Console kernels. But, fatal error exceptions must * be handled differently since they are not normal exceptions. * * @param \Throwable $e * @return void */ public function handleException(Throwable $e) { self::$reservedMemory = null; try { $this->getExceptionHandler()->report($e); } catch (Exception $e) { // } if ($this->app->runningInConsole()) { $this->renderForConsole($e); } else { $this->renderHttpResponse($e); } } /** * Render an exception to the console. * * @param \Throwable $e * @return void */ protected function renderForConsole(Throwable $e) { $this->getExceptionHandler()->renderForConsole(new ConsoleOutput, $e); } /** * Render an exception as an HTTP response and send it. * * @param \Throwable $e * @return void */ protected function renderHttpResponse(Throwable $e) { $this->getExceptionHandler()->render($this->app['request'], $e)->send(); } /** * Handle the PHP shutdown event. * * @return void */ public function handleShutdown() { self::$reservedMemory = null; if (! is_null($error = error_get_last()) && $this->isFatal($error['type'])) { $this->handleException($this->fatalErrorFromPhpError($error, 0)); } } /** * Create a new fatal error instance from an error array. * * @param array $error * @param int|null $traceOffset * @return \Symfony\Component\ErrorHandler\Error\FatalError */ protected function fatalErrorFromPhpError(array $error, $traceOffset = null) { return new FatalError($error['message'], 0, $error, $traceOffset); } /** * Determine if the error level is a deprecation. * * @param int $level * @return bool */ protected function isDeprecation($level) { return in_array($level, [E_DEPRECATED, E_USER_DEPRECATED]); } /** * Determine if the error type is fatal. * * @param int $type * @return bool */ protected function isFatal($type) { return in_array($type, [E_COMPILE_ERROR, E_CORE_ERROR, E_ERROR, E_PARSE]); } /** * Get an instance of the exception handler. * * @return \Illuminate\Contracts\Debug\ExceptionHandler */ protected function getExceptionHandler() { return $this->app->make(ExceptionHandler::class); } }