Roots Discourse

PHP Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found


I’ve updated my pinned solution to reflect the new Composer version.


Not sure if this is related to this but I now receive the following error if I want to use WP-CLI directly in the terminal as well as connected via “vagrant ssh”:

PHP Fatal error:  Uncaught Error: Class 'Dotenv\Dotenv' not found in /srv/www/xyz/current/config/application.php:17
Stack trace:
#0 phar:///usr/bin/wp/php/WP_CLI/Runner.php(1070) : eval()'d code(7): require_once()
#1 phar:///usr/bin/wp/php/WP_CLI/Runner.php(1070): eval()
#2 phar:///usr/bin/wp/php/WP_CLI/Runner.php(1032): WP_CLI\Runner->load_wordpress()
#3 phar:///usr/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#4 phar:///usr/bin/wp/php/bootstrap.php(75): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#5 phar:///usr/bin/wp/php/wp-cli.php(23): WP_CLI\bootstrap()
#6 phar:///usr/bin/wp/php/boot-phar.php(8): include('phar:///usr/bin...')
#7 /usr/bin/wp(4): include('phar:///usr/bin...')
#8 {main}
  thrown in /srv/www/xyz/current/config/application.php on line 17

I already switched back to composer_keep_updated: true and run ANSIBLE_TAGS=composer vagrant provision. But with composer 1.5.6 and 1.6.2 I get the same result.

Thank you again and best regards,


unpinned #24


I’ve spooled up a fresh install and I’m getting the following error:

non-zero return code
PHP Fatal error: Uncaught Error: Call to undefined method
Dotenv\Dotenv::create() in /srv/www/

Since I’m replying to a year old thread, not sure if this is still relevant but I’ve performed the following without any luck:

rm -rf vendor/
sudo rm /usr/local/bin/composer
chmod +x composer.phar
sudo mv composer.phar /usr/local/bin/composer
composer install

I’m able to provision the server locally and on a DO droplet but when I attempt a deploy, I get the error above.

Prior to attempting my first deploy, I first installed all my composer dependencies and was given an error when composer attempts to install: philippbaschke/acf-pro-installer

The error states that it requires phpdotenv 2.2 so I changed the version from 3.0.0 to 2.2 and ran composer update which then throws the error from above.

I reverted back to the default composer file supplied with Bedrock and I’m still getting the same error.


We’ve updated our guide for ACF to recommend a different installer repository as a solution to this problem.


Thank you for that!

Even without, after reverting back to the default bedrock composer file, I still receive the error.


You need to use a different syntax depending on which version of phpdotenv you’re using. See:


Still having troubles and receiving the same error. Here are what the following files now look like:




Here’s the full error output:

non-zero return code
PHP Fatal error:  Uncaught Error: Call to undefined method
Dotenv\Dotenv::create() in
Stack trace:
#0 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) :
eval()'d code(7): require_once()
#1 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150):
#2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1111):
#3 phar:///usr/bin/wp/vendor/wp-cli/wp-
cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#4 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\Boot
#5 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(23):
#6 phar:///usr/bin/wp/php/boot-phar.php(11): include('phar:///usr/bin...')
#7 /usr/bin/wp(4): include('phar:///usr/bin...')
#8 {main}
  thrown in
/srv/www/ on line
fatal: []: FAILED! => {
    "changed": false, 
    "cmd": [
    "delta": "0:00:00.119577", 
    "end": "2019-02-28 18:30:46.799589", 
    "failed": true, 
    "failed_when_result": true, 
    "invocation": {
        "module_args": {
            "_raw_params": "wp core is-installed --skip-plugins --skip-themes --require=/srv/www/", 
            "_uses_shell": false, 
            "chdir": "/srv/www/", 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "warn": true
    "rc": 255, 
    "start": "2019-02-28 18:30:46.680012", 
    "stderr_lines": [
        "PHP Fatal error:  Uncaught Error: Call to undefined method Dotenv\\Dotenv::create() in /srv/www/", 
        "Stack trace:", 
        "#0 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) : eval()'d code(7): require_once()", 
        "#1 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150): eval()", 
        "#2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1111): WP_CLI\\Runner->load_wordpress()", 
        "#3 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\\Runner->start()", 
        "#4 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\\Bootstrap\\LaunchRunner->process(Object(WP_CLI\\Bootstrap\\BootstrapState))", 
        "#5 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(23): WP_CLI\\bootstrap()", 
        "#6 phar:///usr/bin/wp/php/boot-phar.php(11): include('phar:///usr/bin...')", 
        "#7 /usr/bin/wp(4): include('phar:///usr/bin...')", 
        "#8 {main}", 
        "  thrown in /srv/www/ on line 27"
    "stdout": "", 
    "stdout_lines": []


@swalkinshaw Am I suppose to run this command from my trellis local directory?

I tried this command from my trellis local directory, but I still have the same error, for this reason, I am wondering if I have to run this from another directory.

I had this Class ‘Dotenv\Dotenv’ not found error, after I run from my Trellis local directory:
vagrant ssh
cd /srv/www/
composer update

any suggestion? what else I can try? :cold_face: