Symfony 4: Dotenv::populate returns none

Viewed 4620

I am trying to run a Symfony4 app on production and I am getting the following error:

Uncaught TypeError: Return value of Symfony\\Component\\Dotenv\\Dotenv::populate() 
must be an instance of Symfony\\Component\\Dotenv\\void, 
none returned in /var/www/html/vendor/symfony/dotenv/Dotenv.php:95
Stack trace:
#0 /var/www/html/vendor/symfony/dotenv/Dotenv.php(57): 
    Symfony\\Component\\Dotenv\\Dotenv->populate(Array)
#1 /var/www/html/public/index.php(12): 
    Symfony\\Component\\Dotenv\\Dotenv->load('/var/www/html/s...')
#2 {main}
    thrown in /var/www/html/vendor/symfony/dotenv/Dotenv.php on line 95

On local the app is running fine. Once it moves to production, it breaks.

Any idea why this might be happening?

2 Answers

I also had the same issue when I tried to run Symfony 4 on Ubuntu 16.04 server. In my situation I forgot to enable the new php version in the Apache server after upgrading from v7.0 to v7.2 . I hope below details would help you to check on your production server.

Run following command to see which php version is active.
ls /etc/apache2/mods-enabled/php*

Disable previously installed php version.
sudo a2dismod php7.0

Enable new installed php version.
sudo a2enmod php7.2

Do not forget to restart Apache server.

Related