PHPackages                             codeinwp/optimole-sdk - 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. codeinwp/optimole-sdk

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

codeinwp/optimole-sdk
=====================

SDK for Optimole cloud-based image optimization service

v1.2.4(7mo ago)68.0k↑203.3%1MITPHPPHP &gt;=7.4CI failing

Since Apr 7Pushed 7mo ago5 watchersCompare

[ Source](https://github.com/Codeinwp/optimole-php-sdk)[ Packagist](https://packagist.org/packages/codeinwp/optimole-sdk)[ Docs](https://optimole.com)[ RSS](/packages/codeinwp-optimole-sdk/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (8)Versions (10)Used By (0)

Optimole PHP SDK
================

[](#optimole-php-sdk)

[![Actions Status](https://github.com/Codeinwp/optimole-php-sdk/workflows/Continuous%20Integration/badge.svg)](https://github.com/Codeinwp/optimole-php-sdk/actions)

The Optimole PHP SDK makes it easy for PHP developers to integrate [Optimole](https://optimole.com) cloud-based image optimization service in their PHP project.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4

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

[](#installation)

Install the Optimole PHP SDK in your project using composer:

```
$ composer require codeinwp/optimole-sdk

```

Usage
-----

[](#usage)

To begin, you need to create an account on [Optimole](https://optimole.com) and get your API key.

### Initializing the SDK

[](#initializing-the-sdk)

You can then initialize the SDK with your API key using the `Optimole` facade:

```
use Optimole\Sdk\Optimole;

Optimole::init('your-api-key', $options);
```

The second argument of the `init` method is optional. It allows you to pass options to the SDK that can be used to configure it. These options are:

- `base_domain`: The base domain to connect to Optimole's API. Default is `i.optimole.com`.
- `cache_buster`: A string value that will be appended to the URL of the optimized assets to bust Optimole's cache.
- `dashboard_api_url`: The URL of the dashboard API. Default is `https://dashboard.optimole.com/api`.
- `dashboard_api_key`: The API key to use for the dashboard API.
- `upload_api_credentials`: An array with the credentials to use for the upload API. The array should contain the keys `userKey` and `secret`. The default is empty and the SDK will use the API key provided in the `init` method to fetch them from the dashboard API.
- `upload_api_url`: The URL of the upload API. Default is `https://generateurls-prod.i.optimole.com/upload`.

### Optimizing Images and Assets

[](#optimizing-images-and-assets)

The `Optimole` facade is your starting point for creating optimized images or other assets. You can control the optimization properties using the fluent interface provided by the SDK. Here's an example of how to optimize an image by changing its quality and cropping it:

```
use Optimole\Sdk\Optimole;

$image = Optimole::image('https://example.com/image.jpg')->quality(80)->resize('crop');
```

You can get the optimized image URL using the `getUrl` method or casting the object to a string:

```
echo $image->getUrl();
echo (string) $image;
```

### Offloading Images to Optimole

[](#offloading-images-to-optimole)

The SDK also provides a way to offload images to Optimole. This is useful when you want to serve images from Optimole's content delivery network. Here's an example of how to offload an image:

```
use Optimole\Sdk\Optimole;

$imageId = Optimole::offload()->uploadImage('path/to/image.jpg', 'https://url/to/image.jpg');
```

This will upload the image to Optimole and return the image ID. You can then use this image ID to interact with the image. For example, you can get the URL of the offloaded image:

```
use Optimole\Sdk\Optimole;

$imageUrl = Optimole::offload()->getImageUrl($imageId);
```

Contributing
------------

[](#contributing)

Install dependencies using composer and run the test suite:

```
$ composer install
$ vendor/bin/phpunit
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance62

Regular maintenance activity

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~83 days

Recently: every ~126 days

Total

8

Last Release

231d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3330746?v=4)[Marius Cristea](/maintainers/selul)[@selul](https://github.com/selul)

---

Top Contributors

[![carlalexander](https://avatars.githubusercontent.com/u/654684?v=4)](https://github.com/carlalexander "carlalexander (15 commits)")[![selul](https://avatars.githubusercontent.com/u/3330746?v=4)](https://github.com/selul "selul (15 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/codeinwp-optimole-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/codeinwp-optimole-sdk/health.svg)](https://phpackages.com/packages/codeinwp-optimole-sdk)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[getgrav/grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS

15.6k86.4k1](/packages/getgrav-grav)[guzzlehttp/uri-template

A polyfill class for uri\_template of PHP

196250.8M101](/packages/guzzlehttp-uri-template)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2603.2M435](/packages/ssch-typo3-rector)

PHPackages © 2026

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