我使用此代码:
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行
也许您忘记了名称空间:
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();