PHPackages                             octosqueeze/php-client - 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. [API Development](/categories/api)
4. /
5. octosqueeze/php-client

ActiveLibrary[API Development](/categories/api)

octosqueeze/php-client
======================

OctoSqueeze PHP API Client

1.0.2(2y ago)0120MITPHPPHP ^7.3 || ^8.0

Since Jan 13Pushed 1mo ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (5)Used By (0)

OctoSqueeze PHP Client
======================

[](#octosqueeze-php-client)

Official PHP client for the OctoSqueeze API. Compress images, convert to WebP/AVIF, and optimize for the web.

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

[](#installation)

```
composer require octosqueeze/php-client
```

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

[](#requirements)

- PHP 8.0 or higher
- Guzzle HTTP client

Quick Start
-----------

[](#quick-start)

```
use OctoSqueeze\Client\OctoSqueeze;

$client = OctoSqueeze::client('your-api-key');

// Compress from URL
$result = $client->compressUrl('https://example.com/image.jpg');

if ($result['state']) {
    $compressed = $result['items'][0];
    echo "Original: {$compressed['original_size']} bytes\n";
    echo "Compressed: {$compressed['compressed_size']} bytes\n";
    echo "Savings: {$compressed['savings_percent']}%\n";
}
```

Usage
-----

[](#usage)

### Initialize Client

[](#initialize-client)

```
use OctoSqueeze\Client\OctoSqueeze;

$client = OctoSqueeze::client('your-api-key');

// Optional: Set custom endpoint (for self-hosted or testing)
$client->setEndpointUri('https://api.octosqueeze.com/api/v1');

// Optional: Set default options
$client->setOptions([
    'mode' => 'balanced',      // 'quality', 'balanced', or 'size'
    'formats' => ['webp', 'avif'],
]);
```

### Compress from URL

[](#compress-from-url)

```
// Single URL
$result = $client->compressUrl('https://example.com/image.jpg');

// With options
$result = $client->compressUrl('https://example.com/image.jpg', [
    'mode' => 'quality',
    'formats' => ['webp'],
]);
```

### Compress from File

[](#compress-from-file)

```
$result = $client->compressFile('/path/to/image.jpg');

if ($result['state']) {
    echo "Compression successful!\n";
    print_r($result['data']);
}
```

### Batch Compression

[](#batch-compression)

```
$items = [
    ['url' => 'https://example.com/image1.jpg'],
    ['url' => 'https://example.com/image2.jpg'],
    ['url' => 'https://example.com/image3.jpg', 'options' => ['mode' => 'size']],
];

$result = $client->squeezeUrl($items);

if ($result['state']) {
    foreach ($result['items'] as $item) {
        echo "{$item['name']}: {$item['savings_percent']}% saved\n";
    }
}
```

### Download Compressed Image

[](#download-compressed-image)

```
$result = $client->download($downloadUrl);

if ($result['state']) {
    file_put_contents('/path/to/output.webp', $result['data']);
}

// Or use the convenience method that returns raw content or null:
$content = $client->downloadRaw($downloadUrl);

if ($content) {
    file_put_contents('/path/to/output.webp', $content);
}
```

### Check Usage

[](#check-usage)

```
$usage = $client->getUsage();

if ($usage['state']) {
    echo "Images this month: {$usage['data']['images_this_month']}\n";
    echo "Limit: {$usage['data']['monthly_limit']}\n";
}
```

### Get Compression Status

[](#get-compression-status)

```
$status = $client->getStatus($jobId);

if ($status['state']) {
    echo "Status: {$status['data']['status']}\n";
}
```

Compression Modes
-----------------

[](#compression-modes)

ModeDescriptionTypical Savings`quality`Maximum quality, minimal compression40-55%`balanced`Optimal balance (recommended)60-75%`size`Maximum compression70-85%Output Formats
--------------

[](#output-formats)

- `jpeg` - Standard JPEG output
- `png` - PNG output (with lossless option)
- `webp` - WebP format (30% smaller than JPEG)
- `avif` - AVIF format (50% smaller than JPEG)

Error Handling
--------------

[](#error-handling)

```
$result = $client->compressUrl('https://example.com/image.jpg');

if (!$result['state']) {
    echo "Error: {$result['error']}\n";
    echo "Code: {$result['code']}\n";
}
```

HTTP Client Configuration
-------------------------

[](#http-client-configuration)

```
// Disable SSL verification (for development only)
$client->setHttpClientConfig([
    'verify' => false,
]);

// Set custom timeout
$client->setHttpClientConfig([
    'timeout' => 60,
]);
```

Links
-----

[](#links)

- [OctoSqueeze Website](https://octosqueeze.com)
- [API Documentation](https://octosqueeze.com/api)
- [Get API Key](https://octosqueeze.com/pricing)

License
-------

[](#license)

MIT License - see LICENSE file for details.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance60

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

853d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/760e9e0951553fd63640108d46b90adc3b37cdcd3b0d23e5c5acbfb2783491ba?d=identicon)[octosqueeze](/maintainers/octosqueeze)

---

Top Contributors

[![octosqueeze](https://avatars.githubusercontent.com/u/156412546?v=4)](https://github.com/octosqueeze "octosqueeze (6 commits)")

---

Tags

phpapiclientoctosqueeze

### Embed Badge

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

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[picqer/sendcloud-php-client

A PHP Client for the SendCloud API

45400.4k1](/packages/picqer-sendcloud-php-client)[sima-land/api-php-client

Client library for Simaland APIs

311.5k](/packages/sima-land-api-php-client)

PHPackages © 2026

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