Skip to content
smallPict

SDK officiel pour PHP

Paquet smallpict/smallpict-php pour Laravel, Symfony et applications PHP classiques.

Compatible de PHP 7.4 à PHP 8.3+, conforme aux recommandations de standards PSR-7 et PSR-18.


Installation

Shell
composer require smallpict/smallpict-php

Exemple complet d'utilisation

PHP
<?phprequire 'vendor/autoload.php';
use SmallPict\Client as SmallPictClient;
$client = new SmallPictClient(    getenv('SMALLPICT_API_KEY'),    getenv('SMALLPICT_SECRET_KEY'));
// 1. Optimiser une image$fileData = file_get_contents('photo.jpg');$result = $client->optimize($fileData, [    'format'  => 'avif',    'quality' => 80]);
echo "URL optimisée : " . $result->url . "\n";echo "Gain : " . $result->savingsPercentage . "%\n";
// 2. Consulter le quota$quota = $client->getQuota();echo "Forfait : " . $quota->plan . "\n";