Officiële PHP SDK
Pakket smallpict/smallpict-php voor Laravel, Symfony en traditionele PHP-projecten.
Geschikt voor PHP 7.4 tot en met PHP 8.3+, met strikte naleving van de standaarden PSR-7 en PSR-18.
Installatie
Shell
composer require smallpict/smallpict-phpCompleet toepassingsvoorbeeld
PHP
<?phprequire 'vendor/autoload.php';
use SmallPict\Client as SmallPictClient;
$client = new SmallPictClient( getenv('SMALLPICT_API_KEY'), getenv('SMALLPICT_SECRET_KEY'));
// 1. Afbeelding optimaliseren$fileData = file_get_contents('photo.jpg');$result = $client->optimize($fileData, [ 'format' => 'avif', 'quality' => 80]);
echo "Geoptimaliseerde URL: " . $result->url . "\n";echo "Besparing: " . $result->savingsPercentage . "%\n";
// 2. Quotum opvragen$quota = $client->getQuota();echo "Pakket: " . $quota->plan . "\n";