【问题标题】:Auth0 PHP Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found inAuth0 PHP 致命错误:未捕获的错误:类 'Dotenv\Dotenv' 未在
【发布时间】: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'”。你认为它应该去其他地方吗?

标签: php xampp auth0


【解决方案1】:

阅读 Google 的登录 API 后,我意识到您需要在 composer.json 所在的位置运行“composer install”,这似乎已经解决了这个问题。如果不是这种情况,我会更新这个。

【讨论】:

  • 您好,我遇到了问题。你修好了吗?
猜你喜欢
  • 2021-06-22
  • 2016-09-09
  • 2016-09-17
  • 2022-12-10
  • 2017-05-16
  • 1970-01-01
  • 1970-01-01
  • 2023-03-25
  • 1970-01-01
相关资源
最近更新 更多