So I would like to use a third-party library (Cloudinary for PHP) in a new plugin. I have looked at quite a few other plugins that include third-party libraries in one way or another, and I get the feeling that this should be pretty simple. But I'm also pretty sure that I'm missing some key bits of understanding here, because I can't get it to work. This is what I've got so far:
File structure:
user/plugins/cloudinary/
user/plugins/cloudinary/vendor/cloudinary_php/
The latter contains the library as a git submodule.
Then in my cloudinary.php file, I include it like this:
require_once(__DIR__.'/vendor/autoload.php');
This file was created by running composer.phar install in the plugin's directory, after adding the library to composer.json. (Apparently this also created another directory with the third-party code in user/plugins/cloudinary/vendor/cloudinary/cloudinary_php/.)
However, upon doing $test = new Cloudinary('fat_bunny'); in cloudinary.php, I get a Crikey error that says "Class 'Grav\Plugin\Cloudinary' not found". If I include the autoload.php file that's in the submodule directory:
require_once(__DIR__.'/vendor/cloudinary_php/autoload.php');
the Crikey error says:
"cloudinary_autoloader(): Failed opening required '/home/anna/toolkit/grav-cloudinary/user/plugins/cloudinary/vendor/cloudinary_php/src/Grav\Plugin\Cloudinary.php' (include_path='.:/usr/share/php')
I think a blow-by-blow account of how exactly to get Composer stuff included in Grav would definitely help me out, but I haven't found one yet, so I intend to fumble my way through this and then write it up :-) So can someone point me in the right direction please? What am I not getting here? And generally speaking, which is the better way to go: get the library as a submodule from Git, or install it with Composer? And how do people get it when they install the plugin then?!