Skip to content

Commit

Permalink
Don't use getenv(), use $_SERVER instead
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Aug 30, 2017
1 parent 4af9be7 commit 6c68743
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ if (!class_exists(Application::class)) {
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

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

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

if ($debug && class_exists(Debug::class)) {
Debug::enable();
Expand Down
6 changes: 3 additions & 3 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
require __DIR__.'/../vendor/autoload.php';

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

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

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

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

0 comments on commit 6c68743

Please sign in to comment.