Issues (13)

public/index.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the mailserver-admin package.
6
 * (c) Jeffrey Boehm <https://github.com/jeboehm/mailserver-admin>
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
use App\Kernel;
12
use Symfony\Component\Dotenv\Dotenv;
13
use Symfony\Component\ErrorHandler\Debug;
14
use Symfony\Component\HttpFoundation\Request;
15
16
require __DIR__ . '/../vendor/autoload.php';
17
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
26
$env = $_SERVER['APP_ENV'] ?? 'dev';
27
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
28
29
if ($debug) {
30
    umask(0000);
31
32
    Debug::enable();
33
}
34
35
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
36
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
0 ignored issues
show
Deprecated Code introduced by
The constant Symfony\Component\HttpFo...:HEADER_X_FORWARDED_ALL has been deprecated: since Symfony 5.2, use either "HEADER_X_FORWARDED_FOR | HEADER_X_FORWARDED_HOST | HEADER_X_FORWARDED_PORT | HEADER_X_FORWARDED_PROTO" or "HEADER_X_FORWARDED_AWS_ELB" or "HEADER_X_FORWARDED_TRAEFIK" constants instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

36
    Request::setTrustedProxies(explode(',', $trustedProxies), /** @scrutinizer ignore-deprecated */ Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
37
}
38
39
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
40
    Request::setTrustedHosts(explode(',', $trustedHosts));
41
}
42
43
$kernel = new Kernel($env, $debug);
44
$request = Request::createFromGlobals();
45
$response = $kernel->handle($request);
46
$response->send();
47
$kernel->terminate($request, $response);
48