1
votes

I use this code:

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

But I get error :

Fatal error: Uncaught Error: Class 'ClientRepository' not found in /home/a/public_html/app/oauth2.php:23 Stack trace: #0 {main} thrown in /home/a/public_html/app/oauth2.php on line 23

1
You should probably use ClientRepository as well, or instead of ClientRepositoryInterface - Kyrre
Possible duplicate of How to autoload with composer? - Ogreucha
I added use League\OAuth2\Server\Repositories\ClientRepository; but not work - user12330913
@Ogreucha I read that reply, but not work for me - user12330913
@user12330913 you have to create your own ClientRepository class as mentioned in that answer. - Ogreucha

1 Answers

0
votes

Maybe, you forgot namespace:

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