Problem
Using deployer in a Symfony 6 applaction has required me to change from deployer/deployer
to deployer/dist
(7.0.0-rc.3
), with the downside being that I cannot load enviroment variables from my .env
anymore with the way I used to do it.
Situation
With deployer/deployer
I had the following example to use the dotenv variables in the deploy script:
<?php
namespace Deployer;
use Symfony\Component\Dotenv\Dotenv;
require 'recipe/common.php';
require 'contrib/discord.php';
$dotenv = new Dotenv();
$dotenv->loadEnv(__DIR__ . '/.env');
set('application', $_ENV['APP_NAME']);
set('discord_channel', $_ENV['DISCORD_DEPLOY_CHANNEL']);
set('discord_token', $_ENV['DISCORD_DEPLOY_TOKEN']);
But with deployer/dist
I can no longer do this, giving the error message:
Class "Symfony\Component\Dotenv\Dotenv" not found
Could someone firstly explain why it isn't working anymore? And secondly, what could be a possible solution (or alternative) for loading the environment variables from my .env
file?