如何解决FusionAuth php客户端错误“ FusionAuthClient”未找到?

时间:2019-05-30 05:59:46

标签: fusionauth

当我关注https://github.com/FusionAuth/fusionauth-php-client

我可以看到错误:

PHP Fatal error:  Uncaught Error: Class 'FusionAuthClient' not found ... on line 6

我的应用程序如下:

  First application
  <?php
  require_once 'FusionAuthClient.php';

  $apiKey = "7W-yBfeXfniDhu8PR_h0dGkSsPDJlpUYuP9rP2xXd_4";
  $client = new FusionAuthClient($apiKey, "http://localhost:9011");

第6行在最后。

作曲家说没事

$ composer require fusionauth/fusionauth-client
Using version ^1.6 for fusionauth/fusionauth-client
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing fusionauth/fusionauth-client (1.6.1)
    Downloading: 100%         

Writing lock file
Generating autoload files

FusionAuthClient.phpClientResponse.phpRESTClient.php与我的测试脚本位于同一目录。

您能指出正确的方向是什么原因吗?

2 个答案:

答案 0 :(得分:2)

您是否查看过FusionAuthClient.php文件的第一行?显然不是。

namespace FusionAuth;

因此,该类不在全局名称空间中,因此您需要告诉php它在哪个名称空间中:

$client = new FusionAuth\FusionAuthClient($apiKey, "http://localhost:9011");

不客气。

答案 1 :(得分:0)

看起来require_once函数路径无效

使用“ require”而不是“ require_once”时是否有相同的错误?