cerpus / imageservice-client
Client to handle communication with the Cerpus ImageService
Installs: 6 795
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- cerpus/cerpushelper: ^1.6 || ^2.0
- illuminate/support: ^8.0||^9.0||^10.0
- nesbot/carbon: ^2.0
Requires (Dev)
- fakerphp/faker: ^1.17
- orchestra/testbench: ^6.23|^7.0
- phpunit/phpunit: ^9.5
- shrikeh/teapot: ^2.3
This package is auto-updated.
Last update: 2024-10-18 15:10:29 UTC
README
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.