致命错误:未捕获的错误:未找到类“ ClientRepository”

我使用以下代码:

require_once __DIR__."/vendor/autoload.php";

use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\PasswordGrant;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;

$clientRepository = new ClientRepository();

但是我得到了错误:

  

致命错误:未捕获的错误:找不到类'ClientRepository'   /home/a/public_html/app/oauth2.php:23堆栈跟踪:#0 {main}被抛出   /home/a/public_html/app/oauth2.php,第23行

okletsgo 回答:致命错误:未捕获的错误:未找到类“ ClientRepository”

也许您忘记了命名空间:

require_once __DIR__."/vendor/autoload.php";

use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\PasswordGrant;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;

use NamespaceClass\ClientRepository; <-- edit

$clientRepository = new ClientRepository();
本文链接:https://www.f2er.com/3153744.html

大家都在问