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 DotenvDotenv(__DIR__);
$dotenv->load();
So startup.php
loads vendor/autoload.php
, which loads vlucas/phpdotenv
, after which we can then find DotenvDotenv
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…