public/index.php line 86

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