PHP code example of livetyping / yii2-hermitage-client

1. Go to this page and download the library: Download livetyping/yii2-hermitage-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

livetyping / yii2-hermitage-client example snippets


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



/** @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>');