PHP library to communicate with the Cerpus Image Service
Use composer to require the package
composer require cerpus/imageservice-client
When composer has finished, add the service provider to the providers
array in config/app.php
Cerpus\ImageServiceClient\Providers\ImageServiceClientServiceProvider::class,
Add the following to the alias
array in config/app.php
'ImageService' => \Cerpus\ImageServiceClient\ImageServiceClient::class,
Publish the config file from the package
php artisan vendor:publish --provider="Cerpus\ImageServiceClient\Providers\ImageServiceClientServiceProvider" --tag=config
Not tested, but should work. You are welcome to update this documentation if this does not work!
Add service provider in app/Providers/AppServiceProvider.php
public function register()
{
$this->app->register(Cerpus\ImageServiceClient\Providers\ImageServiceClientServiceProvider::class);
}
Uncomment the line that loads the service providers in bootstrap/app.php
$app->register(App\Providers\AppServiceProvider::class);
Edit config/imageservice-client.php
<?php
return [
"adapters" => [
"imageservice" => [
"handler" => \Cerpus\ImageServiceClient\Adapters\ImageServiceAdapter::class,
"base-url" => '<url to service>',
"system-name" => '<system name>',
],
],
];
Example for a developer setup:
<?php
return [
"adapters" => [
"imageservice" => [
"handler" => \Cerpus\ImageServiceClient\Adapters\ImageServiceAdapter::class,
"base-url" => env('IMAGESERVICE_URL'),
"system-name" => env('VERSION_SYSTEM_NAME')
],
],
];
Resolve from the Laravel Container
$cerpusImage = app(Cerpus\ImageServiceClient\Contracts\ImageServiceContract::class)
or alias
$cerpusImage = ImageService::<Class Method>
or directly
$cerpusImage = new Cerpus\ImageServiceClient\Adapters\ImageServiceAdapter(Client $client, $containerName);
The last one is not recommended.
Method calls return an object or throws exceptions on failure.
get($id) - Returns an ImageDataObject with info on a particular ID
store($filePath, array $metadata = []) - Creates and uploads a new image in one operation.
delete($id) - Delete a file from the image service.
getHostingUrl($id, ImageParamsObject $params) - Returns an url where the file can be found.
getHostingUrls(array $ids) - Returns an array of urls to images
loadRaw($id, $toFile) - Downloads the image to the specified location
getErrors() - Returns an array of occurred errors
See the Confluence Image storage service API documentation
This package is released under the GNU General Public License 3.0. See the
LICENSE
file for more information.