| Q | A
| ----------------- | ---
| Issue Type | Question
| Deployer Version | 6.4.3
| Local Machine OS | MacOS Mojave
| Remote Machine OS | Debian Stretch 9
I'm trying to deploy a Symfony 4 project but i'm struggling with APP_ENV variables.
When I deploy with dep deploy production
I get an error with all tasks involving SYMFONY_ENV=prod because Symfony 4 with flex requires APP_ENV=prod ! (https://symfony.com/doc/current/deployment.html#c-install-update-your-vendors)
How can I change that without having to override all the tasks involving this error ?
Thanks for your help !
You can override by:
set('env', [APP_ENV=>prod]);
But I think we should fix recipe.
Yes, I think we should fix recipe. This is my deployment script for Symfony 4:
//
// Tasks
// =====
desc('Create local .env file');
task('deployer:create-env', function () {
$localEnvPath = "{{release_path}}/.env.local";
if (!test("[ -s $localEnvPath ]")) {
run("echo 'APP_ENV=prod' > $localEnvPath");
writeln('Created file .env.local');
} else {
writeln('File .env.local already exists');
}
});
before('deploy:vendors', 'deployer:create-env');
desc('Dump .env files for production');
task('deploy:dump-env', function () {
$result = run('cd {{release_path}} && {{bin/composer}} dump-env prod');
writeln($result);
});
after('deploy:vendors', 'deploy:dump-env');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'database:migrate');
As you can see I am creating a local .env.local with APP_ENV=prod if it doesn't exist.
This is interesting.
I was seeing that During a deployment, the commands do not respect the .env.local env variable.
I had to manually set it in the recipe to get it to run the environment I wanted.
Is this a feature or a bug?
I think it鈥檚 a bug.
This is interesting.
I was seeing that During a deployment, the commands do not respect the .env.local env variable.I had to manually set it in the recipe to get it to run the environment I wanted.
Is this a feature or a bug?
It seems to be working fine in my previous script. What is happening in your environment?
It seems to be working fine in my previous script. What is happening in your environment?
My apologies.
I had multiple servers and one of them did not have the .env.local setup.
I do like the idea of having set('env', [APP_ENV=>prod]); in the default recipe so that it's fairly easy to see how the Environment is managed during deployments.
I am cleaning up on issues. Fill free to reopen if needed.
Also, we have a new section available: discussions.
Most helpful comment
You can override by:
But I think we should fix recipe.