public/index.php line 83

Open in your IDE?
  1. <?php
  2. // Fixes for AWS - https://symfony.com/doc/current/deployment/proxies.html
  3. // if (isset($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'])) {
  4. //     $_SERVER['HTTP_X_FORWARDED_PROTO'] = $_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'];
  5. //     $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'];
  6. //     // By Adi - My little dirty hack.
  7. //     // AWS sets port to 80 and symfony don't like that when connection is secure and it's trying to redirect app to https://url:80
  8. //     if ('https' === strtolower($_SERVER['REQUEST_SCHEME'])) {
  9. //         $_SERVER['HTTP_X_FORWARDED_PORT'] = '443';
  10. //     }
  11. // }
  12. /*
  13.  * This file is part of Sulu.
  14.  *
  15.  * (c) Sulu GmbH
  16.  *
  17.  * This source file is subject to the MIT license that is bundled
  18.  * with this source code in the file LICENSE.
  19.  */
  20. use App\Kernel;
  21. use Sulu\Component\HttpKernel\SuluKernel;
  22. use Symfony\Component\Dotenv\Dotenv;
  23. use Symfony\Component\ErrorHandler\Debug;
  24. use Symfony\Component\HttpFoundation\Request;
  25. \defined('SULU_MAINTENANCE') || \define('SULU_MAINTENANCE'\getenv('SULU_MAINTENANCE') ?: false);
  26. // maintenance mode
  27. if (SULU_MAINTENANCE) {
  28.     $maintenanceFilePath __DIR__.'/maintenance.php';
  29.     // show maintenance mode and exit if no allowed IP is met
  30.     if (require $maintenanceFilePath) {
  31.         exit();
  32.     }
  33. }
  34. require \dirname(__DIR__).'/vendor/autoload.php';
  35. (new Dotenv())->bootEnv(\dirname(__DIR__).'/.env');
  36. if ($_SERVER['APP_DEBUG']) {
  37.     \umask(0000);
  38.     Debug::enable();
  39. }
  40. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? false) {
  41.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_FOR Request::HEADER_X_FORWARDED_PORT Request::HEADER_X_FORWARDED_PROTO);
  42. }
  43. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? false) {
  44.     Request::setTrustedHosts([$trustedHosts]);
  45. }
  46. // Fixes for AWS - https://symfony.com/doc/current/deployment/proxies.html
  47. // Request::setTrustedProxies(
  48. //     ['127.0.0.1', '10.10.0.0/16', '10.1.0.0/16', 'REMOTE_ADDR'],
  49. //     Request::HEADER_X_FORWARDED_ALL
  50. // );
  51. $suluContext SuluKernel::CONTEXT_WEBSITE;
  52. if (\preg_match('/^\/admin(\/|$)/'$_SERVER['REQUEST_URI'])) {
  53.     $suluContext SuluKernel::CONTEXT_ADMIN;
  54. }
  55. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], $suluContext);
  56. // Comment this line if you want to use the "varnish" http
  57. // caching strategy. See http://sulu.readthedocs.org/en/latest/cookbook/caching-with-varnish.html
  58. if ('dev' !== $_SERVER['APP_ENV'] && SuluKernel::CONTEXT_WEBSITE === $suluContext && !isset($_COOKIE['SULUSESSID'])) {
  59.     $kernel $kernel->getHttpCache();
  60. }
  61. // $kernel = $kernel->getHttpCache();
  62. // When using the HttpCache, you need to call the method in your front controller
  63. // instead of relying on the configuration parameter
  64. // https://symfony.com/doc/3.4/reference/configuration/framework.html#http-method-override
  65. Request::enableHttpMethodParameterOverride();
  66. $request Request::createFromGlobals();
  67. $response $kernel->handle($request);
  68. $response->send();
  69. $kernel->terminate($request$response);