/**
  * Get checking mode by laravel environment.
  *
  * @param string|null $env
  *
  * @return string
  */
 protected function getModeByEnv($env = null)
 {
     if (is_null($env)) {
         $env = $this->app->environment();
     }
     return in_array($env, $this->productionEnvironments) ? 'Production' : 'Dev';
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->isDownForMaintenance() && $this->app->environment() != 'testing') {
         throw new HttpException(503, 'Server is currently undergoing maintenance. We should be ' . 'back up shortly.');
     }
     return $next($request);
 }
Example #3
0
File: Secure.php Project: mlanin/go
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->secure() && $this->app->environment() === 'production') {
         return redirect()->secure($request->getRequestUri());
     }
     return $next($request);
 }
Example #4
0
 /**
  * Determine if the app is running in the console.
  *
  * To allow testing this will return false the environment is testing.
  *
  * @return bool
  */
 public function isRunningInConsole()
 {
     if ($this->app->environment('testing')) {
         return false;
     }
     return $this->app->runningInConsole();
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->environment() === 'production') {
         // for Proxies
         Request::setTrustedProxies([$request->getClientIp()]);
         if (!$request->isSecure()) {
             return redirect()->secure($request->getRequestUri());
         }
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if ('testing' === $this->app->environment() && $request->has('_token')) {
         $input = $request->all();
         $input['_token'] = $request->session()->token();
         // we need to update _token value to make sure we get the POST / PUT tests passed.
         Log::debug('Input token replaced (' . $input['_token'] . ').');
         $request->replace($input);
     }
     return $next($request);
 }
Example #7
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     /** @var \Illuminate\Foundation\Application $app*/
     $env = $app->environment();
     $filesystem = $this->files = new Filesystem();
     $loader = new FileLoader($filesystem, $app['path.config']);
     $config = new Repository($loader, $filesystem, $env);
     $loader->setRepository($config);
     $app->instance('config', $config);
     $configuredLoader = $app['config']->get('laradic_config.loader');
     if (isset($configuredLoader) && $configuredLoader !== 'file') {
         if ($configuredLoader === 'db') {
             $loader = new DatabaseLoader($filesystem, $app['path.config']);
             $config->setLoader($loader);
             $app->booted(function () use($app, $loader, $config) {
                 $loader->setDatabase($app['db']->connection());
                 $loader->setDatabaseTable($app['config']->get('laradic_config.loaders.db.table'));
             });
             $loader->setRepository($config);
         }
     }
     if (file_exists($cached = $app->getCachedConfigPath()) && !$app->runningInConsole()) {
         $items = (require $cached);
         $loadedFromCache = true;
     }
     if (!isset($loadedFromCache)) {
         # $this->loadConfigurationFiles($app, $config);
     }
     date_default_timezone_set($config['app.timezone']);
     mb_internal_encoding('UTF-8');
 }
 /**
  * Register the logger instance in the container.
  *
  * @param  \Illuminate\Foundation\Application|Application $app
  * @return \Illuminate\Log\Writer
  */
 protected function registerLogger(Application $app)
 {
     $logger = new Logger($app->environment());
     //< do not move this! it might produce "Class declarations may not be nested" error
     $log = new Writer($logger, $app['events']);
     $app->instance('log', $log);
     return $log;
 }
Example #9
0
 /**
  * Bootstrap the given application.
  *
  * @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $application
  *
  * @return void
  */
 public function bootstrap(Application $application)
 {
     $loader = new FileLoader(new Filesystem(), $application['path'] . DIRECTORY_SEPARATOR . 'configurations');
     $application->instance('config', $configuration = new Repository($loader, $application->environment()));
     if (!isset($loadedFromCache)) {
         $this->loadConfigurationFiles($application, $configuration);
     }
     mb_internal_encoding('UTF-8');
 }
 protected function getConfigurationFiles(Application $app)
 {
     $configPath = str_finish($app->configPath(), '/');
     $files = $this->getConfigurationFilesInPath($configPath);
     foreach (explode('.', $app->environment()) as $env) {
         $configPath .= $env . '/';
         $files = array_merge_recursive($files, $this->getConfigurationFilesInPath($configPath));
     }
     return $files;
 }
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     $this->app = $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');
     }
 }
Example #12
0
 /**
  * Overwrite the original config value based
  * on environment name.
  *
  * @param array        $configs
  * @param Closure|null $closure
  *
  * @return void
  */
 protected function loadData($configs, Closure $closure = null)
 {
     if (is_null($configs)) {
         return false;
     }
     foreach ($configs as $env => $config) {
         $env = $this->explodeEnvironment($env);
         if (is_array($env)) {
             foreach ($env as $_env) {
                 if ($this->app->environment($_env)) {
                     $closure($config);
                 }
             }
         } else {
             if ($this->app->environment($env)) {
                 $closure($config);
             }
         }
     }
 }
Example #13
0
 /**
  * index.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  * @param \Recca0120\Terminal\Kernel                   $kernel
  * @param \Illuminate\Http\Request                     $request
  * @param \Illuminate\Contracts\Response\Factory       $responseFactory
  * @param \Illuminate\Contracts\Routing\UrlGenerator   $urlGenerator
  * @param string                                       $view
  *
  * @return mixed
  */
 public function index(Application $app, Kernel $kernel, Request $request, ResponseFactory $responseFactory, UrlGenerator $urlGenerator, $view = 'index')
 {
     $kernel->call('--ansi');
     $csrfToken = null;
     if ($request->hasSession() === true) {
         $csrfToken = $request->session()->token();
     }
     $options = json_encode(['csrfToken' => $csrfToken, 'username' => 'LARAVEL', 'hostname' => php_uname('n'), 'os' => PHP_OS, 'basePath' => $app->basePath(), 'environment' => $app->environment(), 'version' => $app->version(), 'endpoint' => $urlGenerator->action('\\' . static::class . '@endpoint'), 'helpInfo' => $kernel->output(), 'interpreters' => ['mysql' => 'mysql', 'artisan tinker' => 'tinker', 'tinker' => 'tinker'], 'confirmToProceed' => ['artisan' => ['migrate', 'migrate:install', 'migrate:refresh', 'migrate:reset', 'migrate:rollback', 'db:seed']]]);
     $id = $view === 'panel' ? Str::random(30) : null;
     return $responseFactory->view('terminal::' . $view, compact('options', 'resources', 'id'));
 }
Example #14
0
 /**
  * Bootstrap the given application.
  *
  * @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $application
  *
  * @return void
  */
 public function bootstrap(Application $application)
 {
     $this->app = $application;
     error_reporting(-1);
     set_error_handler([$this, 'handleError']);
     set_exception_handler([$this, 'handleException']);
     register_shutdown_function([$this, 'handleShutdown']);
     if (!$application->environment('testing')) {
         ini_set('display_errors', 'Off');
     }
     if ($application->make('config')->get('app.debug')) {
         ini_set('display_errors', true);
     }
 }
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     $logger = new Writer(new Monolog($app->environment()), $app['events']);
     // Daily files are better for production stuff
     $logger->useDailyFiles(storage_path('/logs/laravel.log'));
     $app->instance('log', $logger);
     // Next we will bind the a Closure to resolve the PSR logger implementation
     // as this will grant us the ability to be interoperable with many other
     // libraries which are able to utilize the PSR standardized interface.
     $app->bind('Psr\\Log\\LoggerInterface', function ($app) {
         return $app['log']->getMonolog();
     });
     $app->bind('Illuminate\\Contracts\\Logging\\Log', function ($app) {
         return $app['log'];
     });
 }
 /**
  * Load the configuration items from all of the files.
  *
  * @param  \Illuminate\Contracts\Foundation\Application $app
  * @param  \Illuminate\Contracts\Config\Repository      $repository
  *
  * @return void
  */
 protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
 {
     $env = $app->environment();
     $files = $this->getConfigurationFiles($app);
     $filesByEnv = [];
     foreach ($files as $key => $path) {
         // cascading config 지원을 위하여 별도로 저장.
         if (strpos($key, $env) === 0) {
             $filesByEnv[$key] = $path;
             continue;
         }
         // cascading config 지원을 위하여 laravel 5.0 이상에서 제공하는 nesting config는 지원하지 않음.
         if (strpos($key, '.') !== false) {
             continue;
         }
         $repository->set($key, require $path);
     }
     // cascading config 적용
     $this->mergeEnv($repository, $env, $filesByEnv);
 }
Example #17
0
 /**
  * registerLogger method
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  * @return \Docit\Core\Log\Writer
  */
 protected function registerLogger(Application $app)
 {
     $app->instance('docit.log', $log = new Writer(new Monolog($app->environment()), $app['events']));
     $log->useFiles($app['config']['docit.log.path']);
     return $log;
 }
Example #18
0
 /**
  * Register the logger instance in the container.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app        	
  * @return \Illuminate\Log\Writer
  */
 protected function registerLogger(Application $app)
 {
     $app->instance('log', $log = new Writer(new Monolog($app->environment()), $app['events']));
     return $log;
 }
Example #19
0
 /**
  * Determine if the given event should run based on the Cron expression.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  * @return bool
  */
 public function isDue($app)
 {
     if (!$this->runsInMaintenanceMode() && $app->isDownForMaintenance()) {
         return false;
     }
     return $this->expressionPasses() && $this->runsInEnvironment($app->environment());
 }
Example #20
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     $app->instance('config', $config = new Repository(new FileLoader(new Filesystem(), $app['path.config']), $app->environment()));
     date_default_timezone_set($config['app.timezone']);
 }