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

问题描述 投票:1回答:1

我使用此代码:

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行

php oauth oauth-2.0 autoload
1个回答
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();
© www.soinside.com 2019 - 2024. All rights reserved.