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

时间:2019-11-06 09:01:15

标签: php oauth oauth-2.0 autoload

我使用以下代码:

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行

1 个答案:

答案 0 :(得分:0)

也许您忘记了命名空间:

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();