I’ve never used Composer, and I’m having a bit of trouble wrapping my head around what I need to do here.
I want to use a PHP package that’s only available as a Composer package (and I had a hard time figuring out if it’s even possible to extract it from the Composer wrappings, as I don’t know what I’m doing). So how would I go about getting this into my kirby site so I can take advantage of it?
Get the latest snapshot of the composer.phar or install it on your machine. If you get the phar, put it in the directory of your Kirby site and replace composer with php composer.phar in the following command.
Run composer require joyent/php-manta in the directory of your Kirby site. Composer will create the composer.json and composer.lock files as well as a vendor directory where all source files are downloaded to.
Add this below the first require in your index.php:
require 'vendor'.DS.'autoload.php';
Make sure to upload the vendor directory to your server when you deploy the site.
Now you can start using the package like this:
<?php
use Joyent\Manta\MantaClient;
// ...
$client = new MantaClient();
// ...
That depends on what you are planning to do with code. If you want to create a plugin using that library, you would do the stuff within your plugins directory. You can also just build a wrapper for the package, so that you can easily use it anywhere in your project.
I think I’ll actually need to add it into my trigger that I already have running when an mp3 file is uploaded. I should be able to figure that out, I hope.