PHPackages                             livetyping/hermitage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. livetyping/hermitage

ActiveLibrary[File &amp; Storage](/categories/file-storage)

livetyping/hermitage
====================

RESTful image server

v0.1.3(9y ago)332.8k61MITPHPPHP &gt;=7.0

Since May 18Pushed 9y ago7 watchersCompare

[ Source](https://github.com/LiveTyping/hermitage)[ Packagist](https://packagist.org/packages/livetyping/hermitage)[ RSS](/packages/livetyping-hermitage/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (16)Versions (5)Used By (1)

Hermitage
=========

[](#hermitage)

How often do you have to store images that were uploaded by users? Probably, very often. Putting these images into mobile applications is not so simple, because there are many devices with different parameters. A solution comes with Hermitage.

Hermitage is a micro-service based on Slim. It provides storage, delivery and modification of your images for clients and devices you want. Hermitage can:

- Take and put the image through the simple REST API
- Use local file system or Amazon S3 as a repository. And you can easily write your own adapter if needed.
- Put the image in one of preset formats. You can add your own - it's a matter of seconds!

And all of it is out of the box. Amazing! In addition, Hermitage is very simple and easy to use. The information bellow will cover the details. So, let's begin!

Installation
============

[](#installation)

At first, you will need to install a composer lib and after that - to add a config file, then create an index file for your web-server and set environment variables. You can do it either by hand, or by using pre-setted skeleton ([Hermitage Skeleton](https://github.com/LiveTyping/hermitage-skeleton)) and skip this section.

Run the [Composer](https://getcomposer.org) command to install:

```
composer require livetyping/hermitage ~0.1
```

### Config file

[](#config-file)

You can put your config in `config/main.php` or so.

```
return [
    'root-dir' => dirname(__DIR__),
    'storage-dir' => dirname(__DIR__) . '/storage',

    // your versions
    'images.versions' => [
        /**
         * '{version-name}' => [
         *     'type' => '{manipulator-name}',
         *     // manipulator options
         * ],
         */
        'mini' => [
            'type' => 'resize',
            'height' => 200,
            'width' => 200,
        ],
        'small' => [
            'type' => 'resize',
            'height' => 400,
            'width' => 400,
        ],
        'thumb' => [
            'type' => 'fit',
            'height' => 100,
            'width' => 100,
        ],
    ],

    // parameters for optimization an original image
    'images.optimization-params' => ['maxHeight' => 800, 'maxWidth' => 800, 'interlace' => true],
    'images.manipulator-map' => [
        'resize' => \livetyping\hermitage\foundation\images\processor\manipulators\Resize::class,
        'fit' => \livetyping\hermitage\foundation\images\processor\manipulators\Fit::class,
    ],
    'images.manager-config' => ['driver' => 'gd'],

    // slim framework settings
    'settings.httpVersion' => '1.1',
    'settings.responseChunkSize' => 4096,
    'settings.displayErrorDetails' => false,
];
```

### Environment variables

[](#environment-variables)

Copy the `.env.example` file to a local `.env` and configure it:

```
cp vendor/livetyping/hermitage/.env.example .env
```

The local `.env` file looks like this:

```
AUTH_SECRET=changeme

###
# Adapter
##
STORAGE_ADAPTER=local

# AWS S3
#STORAGE_ADAPTER=s3
#STORAGE_S3_REGION=
#STORAGE_S3_BUCKET=
#STORAGE_S3_KEY=
#STORAGE_S3_SECRET=

```

***NOTE:*** Set `AUTH_SECRET` to some random string.

### Index file

[](#index-file)

You can put it in `public/index.php` or so.

```
require __DIR__ . '/../vendor/autoload.php';

$sources = new \livetyping\hermitage\app\Sources([
    // path to your config
    __DIR__ . '/../config/main.php',
]);

// load environment variables from the `.env` file if it exists
livetyping\hermitage\bootstrap\load_dotenv(dirname(__DIR__));
livetyping\hermitage\bootstrap\app($sources)->run();
```

REST API
========

[](#rest-api)

Hermitage provides a simple API so you could upload, download and delete your images.

### Signing write requests

[](#signing-write-requests)

To write to Hermitage a user agent will have to be specified by two request headers: `X-Authenticate-Signature` and `X-Authenticate-Timestamp`.

`X-Authenticate-Signature` is, like the access token, an HMAC (also using SHA-256 and the secret key).

The data for the hash is generated with the following elements:

- HTTP method (POST or DELETE)
- The URI
- UTC timestamp (integer only)

These elements are concatenated in the previous order with `|` as a delimiter character, and the hash is generated with the secret key. The following snippet shows how it can be accomplished with PHP when deleting the image:

```
$timestamp = (new DateTime('now', new DateTimeZone('UTC')))->getTimestamp();
$filename  = '';
$secret    = '';
$method    = 'DELETE';

// The URI
$uri = "http://hermitage/{$filename}";

// Data for the hash
$data = implode('|', [$method, $uri, $timestamp]);

// Generate the signature
$signature = hash_hmac('sha256', $data, $secret);

// Request the uri
$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_CUSTOMREQUEST => $method,
    CURLOPT_HTTPHEADER => [
        'X-Authenticate-Timestamp' => $timestamp,
        'X-Authenticate-Signature' => $signature,
    ],
]);
curl_exec($ch);
curl_close($ch);
```

### Upload

[](#upload)

```
curl -XPOST http://hermitage --data-binary @ -H "Content-Type: image/jpeg" -H "X-Authenticate-Timestamp: " -H "X-Authenticate-Signature: "
```

results in:

```
{
    "filename": "generated/path/to/file.jpg"
}
```

### Delete

[](#delete)

Deleting images from Hermitage can be done by requesting image's URIs with `HTTP DELETE`.

```
curl -XDELETE http://hermitage/ -H "X-Authenticate-Timestamp: " -H "X-Authenticate-Signature: "
```

### Get

[](#get)

Getting an original (optimized) version of the image:

```
curl http://hermitage/
```

Getting another version of the image:

```
curl http://hermitage/:
```

where `` is the version name of the image from config file (like "small", "thumb", etc.)

License
=======

[](#license)

Hermitage is licensed under the MIT license.

See the [LICENSE](LICENSE) file for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

4

Last Release

3635d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3209d007425f192de0e0941e6181d2dfd36ed4f00714675ca7fb525c6fd27ed2?d=identicon)[frostealth](/maintainers/frostealth)

![](https://www.gravatar.com/avatar/f09fc5836a61476646aa22b4ee6959f9c15090dc5f767ad8f7d47583b20d9917?d=identicon)[livetyping](/maintainers/livetyping)

---

Top Contributors

[![frostealth](https://avatars.githubusercontent.com/u/1785217?v=4)](https://github.com/frostealth "frostealth (9 commits)")

---

Tags

hermitageimageimage-manipulationimagesimageserverstorageimagestorage

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/livetyping-hermitage/health.svg)

```
[![Health](https://phpackages.com/badges/livetyping-hermitage/health.svg)](https://phpackages.com/packages/livetyping-hermitage)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
