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
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.
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.
just remove/delete the vendor
folder and reinstall with the -> composer install
.
You just need to remove complied.php
from bootstrap\cache
and it will works fine.
Thanks
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();
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.