Yecodeo
Yecodeo

Reputation: 371

Symfony 4.1 error with Dotenv and void class

hello everybody i'm under symfony 4.1 and i got this errors

Fatal 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/mailx/vendor/symfony/dotenv/Dotenv.php:95 Stack trace: #0 
/var/www/mailx/vendor/symfony/dotenv/Dotenv.php(57): 
Symfony\Component\Dotenv\Dotenv->populate(Array) #1 
/var/www/mailx/public/index.php(15): Symfony\Component\Dotenv\Dotenv- 
>load('/var/www/mailx/...') #2 {main} thrown in 
/var/www/mailx/vendor/symfony/dotenv/Dotenv.php on line 95

this happen when try to open home page here is my config :

PHP 7.2.7-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jun 22 2018 08:44:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.7-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

there is no extra code in my project, it's fresh Symfony

Upvotes: 0

Views: 2849

Answers (2)

Yecodeo
Yecodeo

Reputation: 371

well, for symfony 4.1 i don't really know but i downgrade symfony to 3.4 and faced the same problem and the solution is to set the mysql version in config file.

config.yaml

doctrine:
    dbal:
        ...
        server_version: "%database_server_version%"

parameters.yaml

parameters:
    ...
    database_server_version: 5.7

Upvotes: 0

cherrysoft
cherrysoft

Reputation: 1195

Looks like it could be related to PHP version. See related issue on Github.

Some potential causes / fixes:

  1. Depending on how you installed dotenv (see docs) you may need to get rid of vendor folder and run fresh composer install
  2. Downgrade to PHP 7.0 as return types introduced in 7.1 hence the error (obviously not long term solution)

Upvotes: 2

Related Questions