Fatal error: Uncaught Error: Class "Patreon\OAuth" not found

I have a problem with the OAuth class. I did everything as shown here patreon/patreon - Packagist but I still get this error.

The library is installed correctly. In the folder vendor/patreon/patreon/src/OAuth.php the file is available

use Patreon\API; //works
use Patreon\OAuth; //does not work

my composer.json file
“require”: {
“patreon/patreon”: “^1.0”

Maybe someone had such a problem? I didn’t find any similar questions

That’s… very strange. Have you tired reinstalling the package?

Alternatively, you could try restarting the web server/service, as it could be a, admittedly strange, caching issue.

If neither of those work, would you mind sharing more of the code you’re using? Without seeing it I’m not sure how much more I can help past this.

Thank you for any help.
I can’t restart the server because it is hosting.

Here I form a link

$client_id = '123';
$redirect_uri = 'https://mysite/app/donate/api/patreon';
$patreounUrl = 'https://www.patreon.com/oauth2/authorize?response_type=code&client_id=' . $client_id . '&redirect_uri=' . urlencode($redirect_uri) .'&state='.$user['user_id'];

Next, I accept the data on $redirect_uri = ‘https://mysite/app/donate/api/patreon’;

// Require Composer's autoloader.
require_once ''.$_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
use Patreon\API;
use Patreon\OAuth; //error here

if ($_GET['code'] != '' && $_GET['state'] != '' ) {
    $user = htmlspecialchars($_GET['state']);
    $code = htmlspecialchars($_GET['code']);

    $client_id = '123';
    $client_secret = '123';
    $redirect_uri = 'https://mysite/app/donate/api/patreon';

    $oauth_client = new OAuth($client_id, $client_secret); //error here

    $tokens = $oauth_client->get_tokens($code, $redirect_uri);
    $access_token = $tokens['access_token'];
    $refresh_token = $tokens['refresh_token'];

    if ($access_token != '' && $refresh_token != '') {
        echo 'tokens received';
        //actions with the database


    $api_client = new API($access_token);

    //$api_client->api_return_format = 'object';
    $patron_response = $api_client->fetch_user();


The problem was solved by update composer to the latest version.

1 Like

Great to hear you solved it. A better way could be to use github PHP repo for CI purposes.

Packagist is a package manager for PHP. If you follow that link he provided in the first post, you’ll see the link to the github repo you recommend on the right under details. This is where packagist lists the repo source and where packagist itself is pulling the source from. Packagist just let’s him use PHP Composer’s require and update functionality via command line to pull versions from github. There are also several other alternatives to Composer that implement similar functionality.

Very common for PHP projects.