PHP SDK
Official smallpict/smallpict-php package for Laravel, Symfony, and custom PHP applications.
PHP SDK (smallpict/smallpict-php)
The official SmallPict PHP library is compatible with PHP 7.4 through 8.3+.
📦 Installation
composer require smallpict/smallpict-php
🚀 Quickstart Example
<?php
require 'vendor/autoload.php';
use SmallPict\Client as SmallPictClient;
$client = new SmallPictClient(
getenv('SMALLPICT_API_KEY'),
getenv('SMALLPICT_SECRET_KEY')
);
// 1. Optimize an image
$fileData = file_get_contents('photo.jpg');
$result = $client->optimize($fileData, [
'format' => 'avif',
'quality' => 80
]);
echo "Optimized URL: " . $result->url . "\n";
echo "Saved: " . $result->savingsPercentage . "%\n";
// 2. Fetch Quota
$quota = $client->getQuota();
echo "Plan: " . $quota->plan . "\n";
