livetyping/yii2-hermitage-client

Yii2 Hermitage Client Adapter

Installs: 4 980

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 6

Forks: 0

Open Issues: 0

Type:yii2-extension

v0.1.0 2016-05-30 17:06 UTC

This package is not auto-updated.

Last update: 2024-12-21 20:57:40 UTC


README

Yii2 Adapter for Hermitage Client.

Installation

  1. Run the Composer command to install the latest version:

    composer require livetyping/yii2-hermitage-client ~0.1
  2. Add the component to config/main.php:

    'components' => [
        // ...
        'hermitage' => [
            'class' => 'livetyping\hermitage\client\yii2\Component',
            'secret' => '<secret value>',
            'baseUri' => 'http://hermitage',
            // 'algorithm' => 'sha256',
        ],
        // ...
    ],

Usage

<?php

/** @var \livetyping\hermitage\client\contracts\Client $client */
$client = Yii::$app->get('hermitage');

/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $client->upload(file_get_contents('path/to/local/image'));
$filename = json_decode((string)$response->getBody());
$filename = $filename['filename'];

$response = $client->get($filename, '<version name>');

$response = $client->delete($filename);

/** @var \Psr\Http\Message\UriInterface $uri */
$uri = $client->uriFor($filename, '<version name>');

License

Yii2 Hermitage Client is licensed under the MIT License.

See the LICENSE file for more information.