public/index.php line 68

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of Sulu.
  5.  *
  6.  * (c) Sulu GmbH
  7.  *
  8.  * This source file is subject to the MIT license that is bundled
  9.  * with this source code in the file LICENSE.
  10.  */
  11. use App\Kernel;
  12. use Sulu\Component\HttpKernel\SuluKernel;
  13. use Symfony\Component\Dotenv\Dotenv;
  14. use Symfony\Component\ErrorHandler\Debug;
  15. use Symfony\Component\HttpFoundation\Request;
  16. \defined('SULU_MAINTENANCE') || \define('SULU_MAINTENANCE'\getenv('SULU_MAINTENANCE') ?: false);
  17. // maintenance mode
  18. if (SULU_MAINTENANCE) {
  19.     $maintenanceFilePath __DIR__ '/maintenance.php';
  20.     // show maintenance mode and exit if no allowed IP is met
  21.     if (require $maintenanceFilePath) {
  22.         exit;
  23.     }
  24. }
  25. require \dirname(__DIR__) . '/vendor/autoload.php';
  26. (new Dotenv())->bootEnv(\dirname(__DIR__) . '/.env');
  27. if ($_SERVER['APP_DEBUG']) {
  28.     \umask(0000);
  29.     Debug::enable();
  30. }
  31. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? false) {
  32.     Request::setTrustedProxies(\explode(','$trustedProxies), Request::HEADER_X_FORWARDED_FOR Request::HEADER_X_FORWARDED_PORT Request::HEADER_X_FORWARDED_PROTO);
  33. }
  34. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? false) {
  35.     Request::setTrustedHosts([$trustedHosts]);
  36. }
  37. $suluContext SuluKernel::CONTEXT_WEBSITE;
  38. if (\preg_match('/^\/admin(\/|$)/'$_SERVER['REQUEST_URI'])) {
  39.     $suluContext SuluKernel::CONTEXT_ADMIN;
  40. }
  41. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], $suluContext);
  42. // Comment this line if you want to use the "varnish" http
  43. // caching strategy. See http://sulu.readthedocs.org/en/latest/cookbook/caching-with-varnish.html
  44. if ('dev' !== $_SERVER['APP_ENV'] && SuluKernel::CONTEXT_WEBSITE === $suluContext) {
  45.     $kernel $kernel->getHttpCache();
  46. }
  47. // When using the HttpCache, you need to call the method in your front controller
  48. // instead of relying on the configuration parameter
  49. // https://symfony.com/doc/3.4/reference/configuration/framework.html#http-method-override
  50. Request::enableHttpMethodParameterOverride();
  51. $request Request::createFromGlobals();
  52. $response $kernel->handle($request);
  53. $response->send();
  54. $kernel->terminate($request$response);