8000 Rename APP_ENV to APP_MODE by nicolas-grekas · Pull Request #801 · symfony/recipes · GitHub
[go: up one dir, main page]

Skip to content

Rename APP_ENV to APP_MODE #801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Rename APP_ENV to APP_MODE
  • Loading branch information
nicolas-grekas committed Jul 15, 2020
commit d0a32cbf0ce7a773e89d272f6d6fbc858cb96f47
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ files stored in the root of the Symfony project:

{
"env": {
"APP_ENV": "dev"
"APP_MODE": "dev"
}
}

Expand All @@ -207,7 +207,7 @@ and ``.env.dist`` files:
.. code-block:: bash

###> your-recipe-name-here ###
8000 APP_ENV=dev
APP_MODE=dev
###< your-recipe-name-here ###

The ``###> your-recipe-name-here ###`` section separators are needed by Symfony
Expand Down Expand Up @@ -338,7 +338,7 @@ one used by ``symfony/framework-bundle``:
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"env": {
"APP_ENV": "dev",
"APP_MODE": "dev",
"APP_SECRET": "%generate(secret)%"
},
"gitignore": [
Expand Down
4 changes: 2 additions & 2 deletions behat/symfony2-extension/2.1/features/bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

use Symfony\Component\Dotenv\Dotenv;

putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'test');
putenv('APP_MODE='.$_SERVER['APP_MODE'] = $_ENV['APP_MODE'] = 'test');

if (file_exists(dirname(__DIR__, 2).'/config/bootstrap.php')) {
require dirname(__DIR__, 2).'/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__, 2).'/.env');
(new Dotenv('APP_MODE'))->bootEnv(dirname(__DIR__, 2).'/.env');
}
2 changes: 1 addition & 1 deletion phpunit/phpunit/4.7/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="APP_MODE" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
</php>

Expand Down
4 changes: 2 additions & 2 deletions symfony/console/3.3/bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (!class_exists(Application::class)) {

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
putenv('APP_MODE='.$_SERVER['APP_MODE'] = $_ENV['APP_MODE'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
Expand All @@ -37,6 +37,6 @@ if ($_SERVER['APP_DEBUG']) {
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
4 changes: 2 additions & 2 deletions symfony/console/4.4/bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (!class_exists(Application::class)) {

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
putenv('APP_MODE='.$_SERVER['APP_MODE'] = $_ENV['APP_MODE'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
Expand All @@ -37,6 +37,6 @@ if ($_SERVER['APP_DEBUG']) {
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
4 changes: 2 additions & 2 deletions symfony/console/5.1/bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
putenv('APP_MODE='.$_SERVER['APP_MODE'] = $_ENV['APP_MODE'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
Expand All @@ -38,6 +38,6 @@ if ($_SERVER['APP_DEBUG']) {
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
14 changes: 7 additions & 7 deletions symfony/framework-bundle/3.3/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) {
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_MODE']) || ($_SERVER['APP_MODE'] ?? $_ENV['APP_MODE'] ?? $env['APP_MODE']) === $env['APP_MODE'])) {
(new Dotenv(false))->populate($env);
} else {
$path = dirname(__DIR__).'/.env';
$dotenv = new Dotenv(false);

// load all the .env files
if (method_exists($dotenv, 'loadEnv')) {
$dotenv->loadEnv($path);
$dotenv->loadEnv($path, 'APP_MODE'); F438
} else {
// fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added)

Expand All @@ -28,13 +28,13 @@
$dotenv->load($p);
}

if (null === $env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) {
$dotenv->populate(array('APP_ENV' => $env = 'dev'));
if (null === $env = $_SERVER['APP_MODE'] ?? $_ENV['APP_MODE'] ?? null) {
$dotenv->populate(array('APP_MODE' => $env = 'dev'));
}

if ('test' !== $env && file_exists($p = "$path.local")) {
$dotenv->load($p);
$env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env;
$env = $_SERVER['APP_MODE'] ?? $_ENV['APP_MODE'] ?? $env;
}

if (file_exists($p = "$path.$env")) {
Expand All @@ -48,6 +48,6 @@
}

$_SERVER += $_ENV;
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_MODE'] = $_ENV['APP_MODE'] = ($_SERVER['APP_MODE'] ?? $_ENV['APP_MODE'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_MODE'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
2 changes: 1 addition & 1 deletion symfony/framework-bundle/3.3/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"env": {
"APP_ENV": "dev",
"APP_MODE": "dev",
"APP_SECRET": "%generate(secret)%",
"#TRUSTED_PROXIES": "127.0.0.1,127.0.0.2",
"#TRUSTED_HOSTS": "'^(localhost|example\\.com)$'"
Expand Down
2 changes: 1 addition & 1 deletion symfony/framework-bundle/3.3/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
6 changes: 3 additions & 3 deletions symfony/framework-bundle/4.2/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) {
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_MODE']) || ($_SERVER['APP_MODE'] ?? $_ENV['APP_MODE'] ?? $env['APP_MODE']) === $env['APP_MODE'])) {
(new Dotenv(false))->populate($env);
} else {
// load all the .env files
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
}

$_SERVER += $_ENV;
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_MODE'] = $_ENV['APP_MODE'] = ($_SERVER['APP_MODE'] ?? $_ENV['APP_MODE'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_MODE'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
2 changes: 1 addition & 1 deletion symfony/framework-bundle/4.2/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"env": {
"APP_ENV": "dev",
"APP_MODE": "dev",
"APP_SECRET": "%generate(secret)%",
"#TRUSTED_PROXIES": "127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16",
"#TRUSTED_HOSTS": "'^(localhost|example\\.com)$'"
Expand Down
2 changes: 1 addition & 1 deletion symfony/framework-bundle/4.2/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
2 changes: 1 addition & 1 deletion symfony/framework-bundle/4.4/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
2 changes: 1 addition & 1 deletion symfony/framework-bundle/5.1/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
2 changes: 1 addition & 1 deletion symfony/framework-bundle/5.2/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"env": {
"APP_ENV": "dev",
"APP_MODE": "dev",
"APP_SECRET": "%generate(secret)%"
},
"gitignore": [
Expand Down
2 changes: 1 addition & 1 deletion symfony/framework-bundle/5.2/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Debug::enable();
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_MODE'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
1 change: 1 addition & 0 deletions symfony/phpunit-bridge/3.3/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="APP_MODE" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
</php>

Expand Down
1 change: 1 addition & 0 deletions symfony/phpunit-bridge/4.1/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="APP_MODE" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
Expand Down
0