public/index.php line 88

Open in your IDE?
  1. <?php
  2. if (strpos($_SERVER['HTTP_HOST'], 'wunderbit.rocks') >= 0) {
  3.     $_SERVER['REQUEST_SCHEME'] = 'https';
  4.     $_SERVER['HTTPS'] = 'on';
  5. }
  6. use Doctrine\DBAL\DBALException;
  7. use PackageVersions\Versions;
  8. use Shopware\Core\Framework\Adapter\Cache\CacheIdLoader;
  9. use Shopware\Core\Framework\Event\BeforeSendResponseEvent;
  10. use Shopware\Core\Framework\Plugin\KernelPluginLoader\DbalKernelPluginLoader;
  11. use Shopware\Core\Framework\Routing\RequestTransformerInterface;
  12. use Shopware\Production\HttpKernel;
  13. use Shopware\Production\Kernel;
  14. use Shopware\Storefront\Framework\Cache\CacheStore;
  15. use Symfony\Component\Debug\Debug;
  16. use Symfony\Component\Dotenv\Dotenv;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpKernel\HttpCache\HttpCache;
  19. use Doctrine\DBAL\Connection;
  20. if (PHP_VERSION_ID 70200) {
  21.     header('Content-type: text/html; charset=utf-8'true503);
  22.     echo '<h2>Error</h2>';
  23.     echo 'Your server is running PHP version ' PHP_VERSION ' but Shopware 6 requires at least PHP 7.2.0';
  24.     exit();
  25. }
  26. $classLoader = require __DIR__.'/../vendor/autoload.php';
  27. if (!file_exists(dirname(__DIR__) . '/install.lock')) {
  28.     $basePath 'recovery/install';
  29.     $baseURL str_replace(basename(__FILE__), ''$_SERVER['SCRIPT_NAME']);
  30.     $baseURL rtrim($baseURL'/');
  31.     $installerURL $baseURL '/' $basePath '/index.php';
  32.     if (strpos($_SERVER['REQUEST_URI'], $basePath) === false) {
  33.         header('Location: ' $installerURL);
  34.         exit;
  35.     }
  36. }
  37. if (is_file(dirname(__DIR__) . '/files/update/update.json') || is_dir(dirname(__DIR__) . '/update-assets')) {
  38.     header('Content-type: text/html; charset=utf-8'true503);
  39.     header('Status: 503 Service Temporarily Unavailable');
  40.     header('Retry-After: 1200');
  41.     if (file_exists(__DIR__ '/maintenance.html')) {
  42.         readfile(__DIR__ '/maintenance.html');
  43.     } else {
  44.         readfile(__DIR__ '/recovery/update/maintenance.html');
  45.     }
  46.     return;
  47. }
  48. // The check is to ensure we don't use .env if APP_ENV is defined
  49. if (!isset($_SERVER['APP_ENV']) && !isset($_ENV['APP_ENV'])) {
  50.     if (!class_exists(Dotenv::class)) {
  51.         throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
  52.     }
  53.     $envFile __DIR__.'/../.env';
  54.     if (file_exists($envFile)) {
  55.         (new Dotenv(true))->load($envFile);
  56.     }
  57. }
  58. $appEnv $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'dev';
  59. $debug = (bool) ($_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? ('prod' !== $appEnv));
  60. if ($debug) {
  61.     umask(0000);
  62.     Debug::enable();
  63. }
  64. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
  65.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  66. }
  67. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
  68.     Request::setTrustedHosts(explode(','$trustedHosts));
  69. }
  70. $request Request::createFromGlobals();
  71. $kernel = new HttpKernel($appEnv$debug$classLoader);
  72. $result $kernel->handle($request);
  73. $result->getResponse()->send();
  74. $kernel->terminate($result->getRequest(), $result->getResponse());