Skip to content

Commit f6c45c2

Browse files
committed
bug #58 Fixed the handling of Symfony Environment in Symfony 4 (javiereguiluz)
This PR was merged into the 1.0.x-dev branch. Discussion ---------- Fixed the handling of Symfony Environment in Symfony 4 Commits ------- dbdb011 Fixed the handling of Symfony Environment in Symfony 4
2 parents 726000a + dbdb011 commit f6c45c2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Configuration/DefaultConfiguration.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
*/
2424
final class DefaultConfiguration extends AbstractConfiguration
2525
{
26-
// properties are defined as private so the developer don't see them when using
26+
// variables starting with an underscore are for internal use only
27+
private $_symfonyEnvironmentEnvVarName; // SYMFONY_ENV or APP_ENV
28+
29+
// properties are defined as private so the developer doesn't see them when using
2730
// their IDE autocompletion. To simplify things, the builder defines setter
2831
// methods named the same as each option.
2932
private $symfonyEnvironment = 'prod';
@@ -364,19 +367,22 @@ protected function getReservedServerProperties(): array
364367
private function setDefaultConfiguration(int $symfonyMajorVersion, $symfonyMinorVersion): void
365368
{
366369
if (2 === $symfonyMajorVersion) {
370+
$this->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV';
367371
$this->setDirs('app', 'app/config', 'app/cache', 'app/logs', 'src', 'app/Resources/views', 'web');
368372
$this->controllersToRemove(['web/app_*.php']);
369373
$this->sharedFiles = ['app/config/parameters.yml'];
370374
$this->sharedDirs = ['app/logs'];
371375
$this->writableDirs = ['app/cache/', 'app/logs/'];
372376
$this->dumpAsseticAssets = true;
373377
} elseif (3 === $symfonyMajorVersion && 4 < $symfonyMinorVersion) {
378+
$this->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV';
374379
$this->setDirs('bin', 'app/config', 'var/cache', 'var/logs', 'src', 'app/Resources/views', 'web');
375380
$this->controllersToRemove(['web/app_*.php']);
376381
$this->sharedFiles = ['app/config/parameters.yml'];
377382
$this->sharedDirs = ['var/logs'];
378383
$this->writableDirs = ['var/cache/', 'var/logs/'];
379384
} elseif (4 === $symfonyMajorVersion || (3 === $symfonyMajorVersion && 4 >= $symfonyMinorVersion)) {
385+
$this->_symfonyEnvironmentEnvVarName = 'APP_ENV';
380386
$this->setDirs('bin', 'config', 'var/cache', 'var/log', 'src', 'templates', 'public');
381387
$this->controllersToRemove([]);
382388
$this->sharedDirs = ['var/log'];

src/Deployer/AbstractDeployer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ final protected function safeDelete(Server $server, array $absolutePaths): void
211211
private function getCommandEnvVars(): array
212212
{
213213
$symfonyEnvironment = $this->getConfig(Option::symfonyEnvironment);
214-
$envVars = null !== $symfonyEnvironment ? ['SYMFONY_ENV' => $symfonyEnvironment] : [];
214+
$symfonyEnvironmentEnvVarName = $this->getConfig('_symfonyEnvironmentEnvVarName');
215+
$envVars = null !== $symfonyEnvironment ? [$symfonyEnvironmentEnvVarName => $symfonyEnvironment] : [];
215216

216217
return $envVars;
217218
}

0 commit comments

Comments
 (0)