|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -/* |
4 |
| - * This file is part of the Symfony package. |
5 |
| - * |
6 |
| - * (c) Fabien Potencier <fabien@symfony.com> |
7 |
| - * |
8 |
| - * For the full copyright and license information, please view the LICENSE |
9 |
| - * file that was distributed with this source code. |
10 |
| - */ |
11 |
| - |
12 | 3 | use App\Kernel;
|
13 | 4 | use Symfony\Component\Debug\Debug;
|
14 | 5 | use Symfony\Component\Dotenv\Dotenv;
|
|
18 | 9 |
|
19 | 10 | // The check is to ensure we don't use .env in production
|
20 | 11 | if (!isset($_SERVER['APP_ENV'])) {
|
| 12 | + if (!class_exists(Dotenv::class)) { |
| 13 | + 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.'); |
| 14 | + } |
21 | 15 | (new Dotenv())->load(__DIR__.'/../.env');
|
22 | 16 | }
|
23 | 17 |
|
24 |
| -if ($_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))) { |
| 18 | +$env = $_SERVER['APP_ENV'] ?? 'dev'; |
| 19 | +$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)); |
| 20 | + |
| 21 | +if ($debug) { |
25 | 22 | umask(0000);
|
26 | 23 |
|
27 | 24 | Debug::enable();
|
28 | 25 | }
|
29 | 26 |
|
30 |
| -// Request::setTrustedProxies(['0.0.0.0/0'], Request::HEADER_FORWARDED); |
| 27 | +if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) { |
| 28 | + Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST); |
| 29 | +} |
| 30 | + |
| 31 | +if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) { |
| 32 | + Request::setTrustedHosts(explode(',', $trustedHosts)); |
| 33 | +} |
31 | 34 |
|
32 |
| -$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'dev', $_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))); |
| 35 | +$kernel = new Kernel($env, $debug); |
33 | 36 | $request = Request::createFromGlobals();
|
34 | 37 | $response = $kernel->handle($request);
|
35 | 38 | $response->send();
|
|
0 commit comments