cerpus/imageservice-client

Client to handle communication with the Cerpus ImageService
9,417
Install
composer require cerpus/imageservice-client
Latest Version:v2.3.0
PHP:^8.2
License:GPL-3.0-only
Last Updated:Feb 13, 2025
Links: GitHub  ·  Packagist
Maintainer: max_edlib

Cerpus Image Service Client

PHP library to communicate with the Cerpus Image Service

Installation

Use composer to require the package

composer require cerpus/imageservice-client

Laravel

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

Lumen

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 the configuration file

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')
        ],
    ],
];

Usage

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.

Class methods

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

More info

See the Confluence Image storage service API documentation

License

This package is released under the GNU General Public License 3.0. See the LICENSE file for more information.

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444