1
嗯,我很为难找到。我一直在努力工作几个小时,大量的谷歌后来没有。 /咆哮。Auth0 PHP致命错误:未捕获的错误:类“Dotenv Dotenv”不
我是新来Auth0,想出去搏一搏,但我发现下面的错误。我使用他们的PHP示例项目,你可以在这里找到:https://github.com/auth0-samples/auth0-php-web-app/tree/master/00-Starter-Seed/basic-webapp
我已经安装了作曲家和安装的依赖关系。我已经重命名确保我已经正确安装.env。我在XAMPP中运行它。
Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in /Users/.../htdocs/oa/dotenv-loader.php:6
我已经尝试了下面的dotenv-loader.php显示不同的变化,但没有运气。有人有建议吗?
try {
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
} catch(InvalidArgumentException $ex) {
// Ignore if no dotenv
}
// Read .env
$dotenv = new Dotenv\Dotenv('.env');
if(file_exists(".env")) {
$dotenv->load();
}
$dotenv = new Dotenv\Dotenv(__DIR__);
//Check if file exists the same way as dotenv does it
//See classes DotEnv\DotEnv and DotEnv\Loader
//$filePath = $dotenv->getFilePath(__DIR__);
//This method is protected so extract code from method (see below)
$filePath = rtrim(__DIR__, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR . '.env';
if(is_file($filePath) && is_readable($filePath)) {
$dotenv->load();
}
非常感谢。
类。你正在使用自动加载,需要/包括或什么加载这个类到你的文件? –
嘿,谢谢你的回复。是的,在index.php中,我打电话给“require'autoload.php'”。有没有其他地方你认为它应该去? – James