Fatal error: Class 'Dotenv\Dotenv' not found in

前端 未结 7 686
悲哀的现实
悲哀的现实 2021-01-18 17:10

Hello guys I am so confused I dont know what I am doing wrong this told me Fatal error: Class \'Dotenv\\Dotenv\' not found in

But I dont understand

相关标签:
7条回答
  • 2021-01-18 17:32

    check if you have "vlucas/phpdotenv" : "~2.2" in "require" tag in composer file. if you don't then add that plugin and open your terminal and run "composer dump-autoload" then run "composer update". and just to be safe run "composer dump-autoload" once again to refresh all the file paths.

    and, if you do have phpdotenv plugin then add that plugin in "require" then just run the dump-autoload command.

    0 讨论(0)
  • 2021-01-18 17:33

    use Dotenv\Dotenv;

    require DIR . '/../vendor/autoload.php';

    $dotenv = new Dotenv(DIR . "/.."); $dotenv->load();

    This is also worked for me. We can Use this.Thank you.

    0 讨论(0)
  • 2021-01-18 17:36

    just remove/delete the vendor folder and reinstall with the -> composer install.

    0 讨论(0)
  • 2021-01-18 17:37

    You just need to remove complied.php from bootstrap\cache and it will works fine.

    Thanks

    0 讨论(0)
  • 2021-01-18 17:37

    For me worked this code:

    use Dotenv\Dotenv;
    
    require __DIR__ . '/../vendor/autoload.php';
    
    $dotenv = new Dotenv(__DIR__ . "/..");
    $dotenv->load();
    

    Instead of this:

    require __DIR__ . '/../vendor/autoload.php';
    
    $dotenv = new Dotenv/Dotenv(__DIR__);
    $dotenv->load();
    
    0 讨论(0)
  • 2021-01-18 17:42

    I'm using the PhpStorm IDE and I installed dotenv on the server via SSH. Subsequently I didn't have the new vendor files in the local directory which caused this error. I simply downloaded the up-to-date vendor folder from the server (overwriting the local one) and the error went away.

    0 讨论(0)
提交回复
热议问题