Using Composer within Sage theme

Hey there,

I’ve just run into a problem when trying to use a Composer package within my Sage theme (8.5.0). I’ve spent a few hours trying to work it out with no luck.

I’m just trying to use a basic Instagram PHP API package (https://packagist.org/packages/vinkla/instagram) and I keep getting the “Fatal error: Uncaught Error: Class ‘Vinkla\Instagram\Instagram’ not found” error when trying to use it.

I’ve spent a couple of hours trying to work it out. I can see the package is in my vendor directory (within the theme). I can see that the package has been added to the autoload_psr4 file. I’ve required in the autoloader. But still no luck.

Do I have to be including the autoloader in a specific theme file or something? I’m just not sure what else to try. At this stage I won’t be using Bedrock either, if that effects anything.

Any help would much appreciated :slight_smile:

Thanks,
Josh

What code have you tried to use the package? You’ll need a use statement of course.

I have use Vinkla\Instagram\Instagram; to use the package.

Although I actually managed to get it working this morning.

For the record, I had to include the autoloader in the functions.php file. I was trying to include it in the Sage lib/setup.php file, which is where I went wrong.

Thanks for getting back to me.

2 Likes