Skip to content

Commit 6c68743

Browse files
committed
Don't use getenv(), use $_SERVER instead
1 parent 4af9be7 commit 6c68743

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

bin/console

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ if (!class_exists(Application::class)) {
1616
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
1717
}
1818

19-
if (!getenv('APP_ENV')) {
19+
if (!isset($_SERVER['APP_ENV'])) {
2020
(new Dotenv())->load(__DIR__.'/../.env');
2121
}
2222

2323
$input = new ArgvInput();
24-
$env = $input->getParameterOption(['--env', '-e'], getenv('APP_ENV') ?: 'dev');
25-
$debug = getenv('APP_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']);
24+
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev');
25+
$debug = ($_SERVER['APP_DEBUG'] ?? true) !== '0' && !$input->hasParameterOption(['--no-debug', '']);
2626

2727
if ($debug && class_exists(Debug::class)) {
2828
Debug::enable();

public/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
require __DIR__.'/../vendor/autoload.php';
1818

1919
// The check is to ensure we don't use .env in production
20-
if (!getenv('APP_ENV')) {
20+
if (!isset($_SERVER['APP_ENV'])) {
2121
(new Dotenv())->load(__DIR__.'/../.env');
2222
}
2323

24-
if (getenv('APP_DEBUG')) {
24+
if ($_SERVER['APP_DEBUG'] ?? true) {
2525
// WARNING: You should setup permissions the proper way!
2626
// REMOVE the following PHP line and read
2727
// https://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup
@@ -32,7 +32,7 @@
3232

3333
// Request::setTrustedProxies(['0.0.0.0/0'], Request::HEADER_FORWARDED);
3434

35-
$kernel = new Kernel(getenv('APP_ENV'), getenv('APP_DEBUG'));
35+
$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'dev', $_SERVER['APP_DEBUG'] ?? true);
3636
$request = Request::createFromGlobals();
3737
$response = $kernel->handle($request);
3838
$response->send();

0 commit comments

Comments
 (0)