EprelService or ComplianceService). Can be injected via container binding or facades for simplicity.Http facade (Guzzle under the hood) is compatible.Symfony HttpClient factory works out-of-the-box.Cache facade (e.g., Redis, file cache) integrates cleanly.AppServiceProvider with config publishing for API keys/endpoints.eprel_products table).spatie/fork) to enforce contracts.illuminate/http).Http facade (Guzzle) as the PSR-18 client.Cache facade (e.g., Redis, database, or file cache).php artisan vendor:publish.$this->app->singleton(EprelClient::class, function ($app) {
return new EprelClient(
httpClient: $app->make(\Illuminate\Http\Client\PendingRequest::class),
cache: $app->make(\Illuminate\Contracts\Cache\Repository::class),
config: $app['config']['eprel']
);
});
products table with:
Schema::create('eprel_products', function (Blueprint $table) {
$table->id();
$table->string('eprel_id');
$table->json('energy_label_data');
$table->timestamps();
});
EprelValidationJob) for async processing.public function validateProduct(EprelClient $client, string $productId) {
$response = $client->search(['productId' => $productId]);
return view('compliance', ['label' => $response->energyLabel]);
}
Http tests to mock API responses..env (e.g., EPREL_API_KEY).guzzlehttp/guzzle and psr/cache are installed (Laravel includes these by default).app/Services/EprelService.php) to wrap the client.public function getEnergyLabel(EprelClient $client, string $productId) {
return $client->search(['productId' => $productId])->energyLabel;
}
spatie/laravel-queue-retries).logs/eprel_errors.log.composer.json to avoid surprises:
"asm/eprel-api-client": "^1.0"
\Log::channel('eprel')->info('Query', ['input' => $query, 'response' => $response]);
EprelApiException).try {
$client->search($query);
} catch (\Asm\EprelApiClient\Exception\ApiException $e) {
throw new \App\Exceptions\ComplianceValidationException($e->getMessage());
}
eprel_productsHow can I help you explore Laravel packages today?