SDK oficial para PHP
Paquete smallpict/smallpict-php para Laravel, Symfony y aplicaciones PHP tradicionales.
La biblioteca oficial de PHP de SmallPict es compatible con PHP 7.4 hasta PHP 8.3+, y se adhiere a los estándares PSR-7 y PSR-18.
Instalación
Shell
composer require smallpict/smallpict-phpEjemplo completo de uso
PHP
<?phprequire 'vendor/autoload.php';
use SmallPict\Client as SmallPictClient;
$client = new SmallPictClient( getenv('SMALLPICT_API_KEY'), getenv('SMALLPICT_SECRET_KEY'));
// 1. Optimizar imagen$fileData = file_get_contents('photo.jpg');$result = $client->optimize($fileData, [ 'format' => 'avif', 'quality' => 80]);
echo "URL optimizada: " . $result->url . "\n";echo "Ahorro: " . $result->savingsPercentage . "%\n";
// 2. Consultar cuota$quota = $client->getQuota();echo "Plan: " . $quota->plan . "\n";