PHP API fatal error

Hi all, I’m slowly learning how to use the PHP API.
I am currently stuck getting the following error:

Fatal error: Interface ‘Art4\JsonApiClient\ResourceItemInterface’ not found in /home/chapelcomic/public_html/mypatreon/vendor/patreon/patreon/src/Patreon/JSONAPI/ResourceItem.php on line 9

Any idea what the cause could be?

This would suggest that you don’t have the Art4\JsonApiClient package installed. This should have been installed when you installed the patreon package because it’s a dependency but it seems the installation of that package failed for some reason.

A first step to try and resolve this would be to install the package manually, e.g:

composer require art4/json-api-client

If that doesn’t help, try deleting your vendor directory then run composer require patreon/patreon again. Do you see any errors?

As a side note, I’ll be releasing a new Patreon PHP library in the coming days that’ll make it much easier to work with the API, keep an eye out for that on this forum this week if you’re struggling with the current PHP library :slight_smile:

Thanks for the quick reply.

I deleted the vendor file and ran ‘composer require patreon/patreon’ again, it looks like it’s all downloaded: https://i.imgur.com/AnHjBP2.png

but still getting the error.

Are you including the Patreon library manually or using the composer autoloader? You need to use the autoloader for dependencies to be available, e.g:

require_once __DIR__ . ‘/vendor/autoload.php’;

$patreon = ...

If that doesn’t help then please share the code you’re using, the contents of the file that is calling the Patreon library.

2 Likes

That’s fixed it, thank you.

I wasn’t using the autoloader.

1 Like