public/index.php line 49

Open in your IDE?
  1. <?php
  2. use App\Kernel;
  3. use Symfony\Component\ErrorHandler\Debug;
  4. use Symfony\Component\Dotenv\Dotenv;
  5. use Symfony\Component\HttpFoundation\Request;
  6. // HGC redirect to my.brunex.ch (discontinued as of 2026-01-01)
  7. if (
  8. strtotime('2026-01-01') <= time()
  9. && isset($_SERVER['HTTP_HOST'])
  10. && str_contains($_SERVER['HTTP_HOST'], 'hgc.brunex.ch')
  11. ) {
  12. $targetUrl = 'https://my.brunex.ch' . ($_SERVER['REQUEST_URI'] ?? '/');
  13. header('HTTP/1.1 301 Moved Permanently');
  14. header('Location: ' . $targetUrl);
  15. exit;
  16. }
  17. require __DIR__.'/../vendor/autoload.php';
  18. // The check is to ensure we don't use .env in production
  19. if (!isset($_SERVER['APP_ENV'])) {
  20. if (!class_exists(Dotenv::class)) {
  21. 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.');
  22. }
  23. (new Dotenv())->load(__DIR__.'/../.env');
  24. }
  25. $env = $_SERVER['APP_ENV'] ?? 'dev';
  26. $debug = $_SERVER['APP_DEBUG'] ?? ('prod' !== $env);
  27. if ($debug) {
  28. umask(0000);
  29. Debug::enable();
  30. }
  31. if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
  32. Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
  33. }
  34. if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
  35. Request::setTrustedHosts(explode(',', $trustedHosts));
  36. }
  37. $kernel = new Kernel($env, $debug);
  38. $request = Request::createFromGlobals();
  39. $response = $kernel->handle($request);
  40. $response->send();
  41. $kernel->terminate($request, $response);