Skip to content

Commit fcc0592

Browse files
ihor-svizievramunasd
authored andcommitted
Retrieve APP_ENV and APP_DEBUG from environment variables
1 parent 9332f4d commit fcc0592

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

public/index.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@
44
use Symfony\Component\HttpFoundation\Request;
55

66
require dirname(__DIR__) . '/config/bootstrap.php';
7-
if ($_SERVER['APP_DEBUG']) {
7+
8+
$appEnv = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'dev';
9+
$appDebug = (bool)($_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? true);
10+
$trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false;
11+
$trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false;
12+
13+
if ($appDebug) {
814
umask(0000);
915
Debug::enable();
1016
}
11-
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
17+
if ($trustedProxies) {
1218
Request::setTrustedProxies(
1319
explode(',', $trustedProxies),
1420
Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST
1521
);
1622
}
17-
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
23+
if ($trustedHosts) {
1824
Request::setTrustedHosts([$trustedHosts]);
1925
}
20-
$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'dev', (bool)($_SERVER['APP_DEBUG'] ?? true));
26+
27+
$kernel = new Kernel($appEnv, $appDebug);
2128
$request = Request::createFromGlobals();
2229
$response = $kernel->handle($request);
2330
$response->send();

0 commit comments

Comments
 (0)