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

Created on 30 June 2021, over 3 years ago
Updated 20 October 2023, about 1 year ago

Hai all,
First i am run the command 'composer install --no-dev' after that i got an error related with autoload file.
For solving this issue i am running the command 'composer dumpautoload' and then autoload file created in the vendor folder and that error was solved. But again i got another error like:
Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in C:\xampp\htdocs\new_dd_test\load.environment.php:14 Stack trace: #0 C:\xampp\htdocs\new_dd_test\vendor\composer\autoload_real.php(73): require() #1 C:\xampp\htdocs\new_dd_test\vendor\composer\autoload_real.php(63): composerRequire5fe40085184f0b7d2f93a2c663a6789c('d511210698f02d8...', 'C:\\xampp\\htdocs...') #2 C:\xampp\htdocs\new_dd_test\vendor\autoload.php(7): ComposerAutoloaderInit5fe40085184f0b7d2f93a2c663a6789c::getLoader() #3 C:\xampp\htdocs\new_dd_test\web\autoload.php(17): require('C:\\xampp\\htdocs...') #4 C:\xampp\htdocs\new_dd_test\web\index.php(14): require_once('C:\\xampp\\htdocs...') #5 {main} thrown in C:\xampp\htdocs\new_dd_test\load.environment.php on line 14

Do you know why this occur? how to resole it?? Please help me to solve this issue

💬 Support request
Status

Closed: outdated

Version

9.3

Component
Other 

Last updated 2 days ago

Created by

🇮🇳India Toby_toby

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States loopy1492

    I got this error recently during an upgrade. I think it happened after BLT 13.7.0 to 13.7.1. I suspect this might have been something that was packaged for a short time along with a composer/blt boilerplate and is now defunct. Removed the reference in composer.json and the file itself.

  • in case anybody else stumbles here.

    @Toby_toby

    You would have to update your load.environment.php file as follows (https://github.com/vlucas/phpdotenv):

    
    <?php
    
    use Dotenv\Dotenv;
    
    /**
     * Load any .env file. See /.env.example.
     *
     * Drupal has no official method for loading environment variables and uses
     * getenv() in some places.
     */
    $dotenv = Dotenv::createUnsafeImmutable(__DIR__);
    $dotenv->safeLoad();
    

    i got the same error after upgrading that package over 2.x and this code fixed it

Production build 0.71.5 2024