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

北城以北 提交于 2019-12-02 02:10:13

Be sure that you are using Dotenv after loading from vendor/autoload.php.

For example, I was using OpenCart, in which contained a file startup.php with:

// Autoloader
if (file_exists(DIR_VENDOR . 'autoload.php')) {
    require_once(DIR_VENDOR . 'autoload.php');
}

And I had defined DIR_VENDOR in config.php as:

define('DIR_VENDOR', __DIR__.'/vendor/');

So finally, in index.php, I would have:

// Startup
require_once(DIR_SYSTEM . 'startup.php');

// dotenv
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();

So startup.php loads vendor/autoload.php, which loads vlucas/phpdotenv, after which we can then find Dotenv\Dotenv.

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.

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

Thanks

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!