Skip to content

Commit

Permalink
bug #58 Fixed the handling of Symfony Environment in Symfony 4 (javie…
Browse files Browse the repository at this point in the history
…reguiluz)

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
  • Loading branch information
javiereguiluz committed Apr 21, 2018
2 parents 726000a + dbdb011 commit f6c45c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Configuration/DefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
*/
final class DefaultConfiguration extends AbstractConfiguration
{
// properties are defined as private so the developer don't see them when using
// variables starting with an underscore are for internal use only
private $_symfonyEnvironmentEnvVarName; // SYMFONY_ENV or APP_ENV

// properties are defined as private so the developer doesn't see them when using
// their IDE autocompletion. To simplify things, the builder defines setter
// methods named the same as each option.
private $symfonyEnvironment = 'prod';
Expand Down Expand Up @@ -364,19 +367,22 @@ protected function getReservedServerProperties(): array
private function setDefaultConfiguration(int $symfonyMajorVersion, $symfonyMinorVersion): void
{
if (2 === $symfonyMajorVersion) {
$this->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV';
$this->setDirs('app', 'app/config', 'app/cache', 'app/logs', 'src', 'app/Resources/views', 'web');
$this->controllersToRemove(['web/app_*.php']);
$this->sharedFiles = ['app/config/parameters.yml'];
$this->sharedDirs = ['app/logs'];
$this->writableDirs = ['app/cache/', 'app/logs/'];
$this->dumpAsseticAssets = true;
} elseif (3 === $symfonyMajorVersion && 4 < $symfonyMinorVersion) {
$this->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV';
$this->setDirs('bin', 'app/config', 'var/cache', 'var/logs', 'src', 'app/Resources/views', 'web');
$this->controllersToRemove(['web/app_*.php']);
$this->sharedFiles = ['app/config/parameters.yml'];
$this->sharedDirs = ['var/logs'];
$this->writableDirs = ['var/cache/', 'var/logs/'];
} elseif (4 === $symfonyMajorVersion || (3 === $symfonyMajorVersion && 4 >= $symfonyMinorVersion)) {
$this->_symfonyEnvironmentEnvVarName = 'APP_ENV';
$this->setDirs('bin', 'config', 'var/cache', 'var/log', 'src', 'templates', 'public');
$this->controllersToRemove([]);
$this->sharedDirs = ['var/log'];
Expand Down
3 changes: 2 additions & 1 deletion src/Deployer/AbstractDeployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ final protected function safeDelete(Server $server, array $absolutePaths): void
private function getCommandEnvVars(): array
{
$symfonyEnvironment = $this->getConfig(Option::symfonyEnvironment);
$envVars = null !== $symfonyEnvironment ? ['SYMFONY_ENV' => $symfonyEnvironment] : [];
$symfonyEnvironmentEnvVarName = $this->getConfig('_symfonyEnvironmentEnvVarName');
$envVars = null !== $symfonyEnvironment ? [$symfonyEnvironmentEnvVarName => $symfonyEnvironment] : [];

return $envVars;
}
Expand Down

0 comments on commit f6c45c2

Please sign in to comment.