public/index.php line 69

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. Debug::enable();
  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. $kernel = new Kernel('dev'true$suluContext);
  43. // Comment this line if you want to use the "varnish" http
  44. // caching strategy. See http://sulu.readthedocs.org/en/latest/cookbook/caching-with-varnish.html
  45. if ('dev' !== $_SERVER['APP_ENV'] && SuluKernel::CONTEXT_WEBSITE === $suluContext) {
  46.     $kernel $kernel->getHttpCache();
  47. }
  48. // When using the HttpCache, you need to call the method in your front controller
  49. // instead of relying on the configuration parameter
  50. // https://symfony.com/doc/3.4/reference/configuration/framework.html#http-method-override
  51. Request::enableHttpMethodParameterOverride();
  52. $request Request::createFromGlobals();
  53. $response $kernel->handle($request);
  54. $response->send();
  55. $kernel->terminate($request$response);