【发布时间】:2017-04-02 18:04:21
【问题描述】:
好吧,我很难过。我一直在尝试解决这个问题几个小时,后来有很多谷歌,但一无所获。 /咆哮。
我是 Auth0 的新手,我想我会试一试,但我收到了下面的错误。我正在使用他们的 PHP 示例项目,您可以在这里找到:https://github.com/auth0-samples/auth0-php-web-app/tree/master/00-Starter-Seed/basic-webapp
我已经安装了 composer 并安装了依赖项。我已重命名以确保我正确设置了 .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'”。你认为它应该去其他地方吗?