Giter Club home page Giter Club logo

php-imageservice-client's Introduction

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.

php-imageservice-client's People

Contributors

emmachughes avatar runarcerpus avatar cerpusoddarne avatar jonepet avatar rypskar avatar

Watchers

Jim Leirvik avatar  avatar Max Moeschinger avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.