PHPackages                             shardimage/shardimage-php - 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. [Image &amp; Media](/categories/media)
4. /
5. shardimage/shardimage-php

ActiveLibrary[Image &amp; Media](/categories/media)

shardimage/shardimage-php
=========================

shardimage-php package

1.0.0-alpha55(4y ago)07.0k↓50%1Apache-2.0PHPPHP ^7.1CI failing

Since Nov 30Pushed 4y agoCompare

[ Source](https://github.com/shardimage/shardimage-php)[ Packagist](https://packagist.org/packages/shardimage/shardimage-php)[ RSS](/packages/shardimage-shardimage-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (57)Used By (1)

Shardimage PHP package
======================

[](#shardimage-php-package)

[![Packagist](https://camo.githubusercontent.com/594672c862c4634d3ef4d5a7a0016e6a345048277c286c9ce95035b15c5bf05b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7368617264696d6167652f7368617264696d6167652d706870)](https://packagist.org/packages/shardimage/shardimage-php)[![Build Status](https://camo.githubusercontent.com/d72875731afca9c070ce7c57d8ef4a611e0862db676738a5bc11cbbaaca420d4/68747470733a2f2f7472617669732d63692e636f6d2f7368617264696d6167652f7368617264696d6167652d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/shardimage/shardimage-php)[![Packagist](https://camo.githubusercontent.com/f4c448b27f2d127dccf2887f407bbc65b4f40287527342ae7045e87d58b75d0c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7368617264696d6167652f7368617264696d6167652d706870)](https://packagist.org/packages/shardimage/shardimage-php)[![GitHub issues](https://camo.githubusercontent.com/872ac9ff345bd9b0818c3c6b2a636100c506c92fed11c3fbe3f123a1cf22f158/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f7368617264696d6167652f7368617264696d6167652d706870)](https://github.com/shardimage/shardimage-php/issues)[![Packagist Version](https://camo.githubusercontent.com/c6eb085932bb3d2ff86c34e137dbcc908e8bb3ce390205d3579d7ded14c47ea3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368617264696d6167652f7368617264696d6167652d706870)](https://packagist.org/packages/shardimage/shardimage-php)[![PHP from Packagist](https://camo.githubusercontent.com/a13c97558bcdac40e3ddda072c015d7ed3b3db54f5b409596cdb2932f49b073b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7368617264696d6167652f7368617264696d6167652d706870)](https://camo.githubusercontent.com/a13c97558bcdac40e3ddda072c015d7ed3b3db54f5b409596cdb2932f49b073b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7368617264696d6167652f7368617264696d6167652d706870)

Introduction
------------

[](#introduction)

Official PHP package for using Shardimage application.

Installation
------------

[](#installation)

### Install With Composer

[](#install-with-composer)

```
composer require shardimage/shardimage-php
```

or add

```
shardimage/shardimage-php:"^1.0"
```

to your `composer.json` file and run update.

Quick start
-----------

[](#quick-start)

Simple examples to use the package. For more details, please read our official documentation &gt;&gt;&gt;

### Configuring the Client

[](#configuring-the-client)

Configure the Client with information from our website to make connection with the Shardimage API.

```
use shardimage\shardimagephp\auth\Client;

$client = new Client([
    'apiKey' => '',             //key to use the API or the image serving
    'apiSecret' => '',       //secret to use the API
    'imageSecret' => '',    //secret to gain more security on image serving
    'cloudId' => '',           //default configuration for cloud ID, it can be overwritten in later usage
]);
```

### Getting access datas

[](#getting-access-datas)

Your `apiKey` and `apiSecret` is available on [Shardimage api](https://shardimage.com/api) page.

Access token can be created through Shardimage API, it requires a configured client with `apiKey` and `apiSecret`.

```
use shardimage\shardimagephp\models\accesstoken\ImageUrlAccessToken;

$accessToken = new ImageUrlAccessToken();
$accessToken->expiry = time() + 3600;
$accessToken->limit = 1000;
$accessToken->extra = [
    'secret' => 'secretString', //
];

$accessToken = $client->getAccessTokenService()->create($accessToken);
if ($accessToken instanceof ImageUrlAccessToken) {
    echo $accessToken->id; //
}
```

Now we can configure an another Client for token image hosting:

```
use shardimage\shardimagephp\auth\Client;

$tokenClient = new Client([
    'apiAccessToken' => ,
    'apiAccessTokenSecret' => , //optional,
]);
```

### Manage clouds with API

[](#manage-clouds-with-api)

To upload and store images, cloud must to be created.

```
use shardimage\shardimagephp\models\cloud\Cloud;
use shardimage\shardimagephp\services\CloudService;

$cloud = new Cloud([
    'name' => 'First Cloud',
    'description' => 'My first Shardimage cloud ever. Awesome!',
]);
```

You can add features to your cloud to make it efficient and secure! To view the full list of our features, please check the documentation &gt;&gt;&gt;

Notice: The `deliverySecureUrl` settings will work only, if you set up the client with the security information: image secret hash or access token/acces token secret.

```
$cloud->settings = [
    //...
    "deliverySecureUrl" => [
        "status" => true    //securing image hosting
    ],
    //...
];
```

Send to the API to create it.

```
$cloud = $client->getCloudService()->create($cloud);
```

If you already have clouds, you can list them:

```
use shardimage\shardimagephp\models\cloud\IndexParams;

$indexParams = new IndexParams();
$indexParams->nextPageToken = 0;
$indexParams->projections = [   //with projections parameter, we have the chance to narrow down the returning data.
    IndexParams::PROJECTION_NO_BACKUP,
    IndexParams::PROJECTION_NO_FIREWALL,
];

$response = $client->getCloudService()->index($indexParams);
```

### Manage images with API

[](#manage-images-with-api)

To upload images to a cloud, or list from it, we need to use the ID of the cloud. The Shardimage PHP package is capable to upload images through single or multithreads, if you have big amount of pictures.

Single thread:

```
$file = __DIR__ . '/' . $file;
$fileName = 'Example';
$result = $client->getUploadService()->upload([
    'file' => $file,
    'cloudId' => ,
    'publicId' => $fileName,
], [    //optional parameters
    'tags' => [
        'example',
        'dump'
    ],
]);
```

If everything goes alright, the `$result` variable will contain `shardimage\shardimagephp\models\image\Image` object with the uploaded image datas.

Multithread upload is very similar, we need to turn on the `defer` option before the upload. Turning it off will send the collected datas.

```
use shardimage\shardimagephp\helpers\UploadHelper;

$files = [
    'file1.jpg',
    'file2.jpg',
    'file3.png',
    'file4.webp',
    'file5.gif',
];
$client->defer(true); //turning on
foreach ($files as $file) {
    $client->getUploadService()->upload([
        'file' => $file,
        'publicId' => UploadHelper::generateRandomPublicId(32),
    ], [
        'tags' => [
            'batch',
            'examples',
        ],
    ]);
}
$result = $client->defer(false); //without turning off, nothing will happen
```

Unwanted pictures can be deleted from the system with two methods. Simple delete will delete one image by it's public ID and the cloud ID.

```
$client->getImageService()->delete([
    'publicId' => ,
    'cloudId' => ,
]);
```

Other way is to delete images by their tags. In this case every images with the given tags will be deleted from the target cloud.

```
$client->getImageService()->delete([
    'cloudId' => ,
    'tag' => '',
]);
```

#### Using `UploadBuilder`

[](#using-uploadbuilder)

Using the builder class can make uploading easier by giving a developer friendly usage to build up upload parameters.

```
use shardimage\shardimagephp\builders\UploadBuilder;

$builder = (new UploadBuilder())
    ->withPrefix('SDK-TEST-')
    ->withRandomPublicId(16)
    ->withTags(['tag1'])
    ->withAddedTags(['added-tag'])
    ->withFilePath($filePath);
$result = $client->getUploadService()->upload($builder->build());
```

### Hosting images

[](#hosting-images)

Hosting the uploaded images with the packgate is basically generating their URL. Using the `UrlService` class you can build up remote image URLs also to serve them through the Shardimage. Practically, the Shardimage will store only the original uploaded image. Every modification, transformation, conversion will applied through URL rules or cloud settings. For further information, please check the documentation &gt;&gt;&gt;

Example for generation URL for stored image:

```
$transformation = Transformation::create();
$transformation->width(200)->height(200)->group();
$url = $client->getUrlService()->create([
    'cloudId' => ,
    'publicId' => ,
], [
    'transformation' => $transformation,
    'security' => 'basic',
]);
echo $url; //https://img.shardimage.com//s-b3:/w:200_h:200/i/
```

Basic security hash will be added to the URL only if you set up the `imageSecret` in your client config.

Changelog
---------

[](#changelog)

All notable changes to this project will be documented in the [CHANGELOG](CHANGELOG.md) file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

License
-------

[](#license)

[Read more &gt;&gt;](https://github.com/shardimage/shardimage-php/blob/master/LICENCE.md)

Links
-----

[](#links)

- [Shardimage](https://shardimage.com)
- [Shardimage documentation](https://developers.shardimage.com)
- [Shardimage blog](https://shardimage.com/blog)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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 ~21 days

Recently: every ~74 days

Total

55

Last Release

1558d ago

PHP version history (2 changes)1.0.0-alpha1PHP ^7.0

1.0.0-alpha42PHP ^7.1

### Community

Maintainers

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

---

Top Contributors

[![walterboyce](https://avatars.githubusercontent.com/u/43808212?v=4)](https://github.com/walterboyce "walterboyce (75 commits)")

---

Tags

shardimageshardimage-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shardimage-shardimage-php/health.svg)

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

###  Alternatives

[spatie/image-optimizer

Easily optimize images using PHP

2.9k71.3M109](/packages/spatie-image-optimizer)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[ps/image-optimizer

Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

9341.7M25](/packages/ps-image-optimizer)[yireo/magento2-next-gen-images

Magento 2 module to add NextGen images support to the Magento frontend

471.1M2](/packages/yireo-magento2-next-gen-images)[godruoyi/ocr

The Best Image Ocr SDK For BAT.

19314.7k1](/packages/godruoyi-ocr)[bravo3/image-manager

A PHP 5.4 library to control dynamic image assets in a cloud environment

158.1k](/packages/bravo3-image-manager)

PHPackages © 2026

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