Offizielles PHP SDK
Paket smallpict/smallpict-php für Laravel, Symfony und Standard-PHP-Anwendungen.
Kompatibel von PHP 7.4 bis 8.3+, entwickelt unter vollständiger Einhaltung der Standards PSR-7 und PSR-18.
Installation
Shell
composer require smallpict/smallpict-phpVollständiges Codebeispiel
PHP
<?phprequire 'vendor/autoload.php';
use SmallPict\Client as SmallPictClient;
$client = new SmallPictClient( getenv('SMALLPICT_API_KEY'), getenv('SMALLPICT_SECRET_KEY'));
// 1. Bild optimieren$fileData = file_get_contents('photo.jpg');$result = $client->optimize($fileData, [ 'format' => 'avif', 'quality' => 80]);
echo "Optimierte URL: " . $result->url . "\n";echo "Ersparnis: " . $result->savingsPercentage . "%\n";
// 2. Kontingent prüfen$quota = $client->getQuota();echo "Tarif: " . $quota->plan . "\n";