public/index.php line 66

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