# PHP SDK

> Install the ShopSavvy PHP SDK with Composer and look up products, offers and price history from PHP 8.1+, Laravel or Symfony applications.

*Source: https://shopsavvy.com/data/documentation/sdk-php* · Part of the [ShopSavvy Data API documentation](https://shopsavvy.com/data/documentation.md)

---

Our official PHP SDK provides easy integration for PHP applications and frameworks like Laravel, Symfony, and CodeIgniter.

- [View on GitHub](https://github.com/shopsavvy/sdk-php)
- Packagist listing pending: install from the GitHub repository as shown below.

## Installation

```bash
composer config repositories.shopsavvy vcs https://github.com/shopsavvy/sdk-php
composer require shopsavvy/shopsavvy-sdk-php
```

## Quick Start

```php
<?php
require_once 'vendor/autoload.php';

use ShopSavvy\Client;

// Create a new client
$client = new Client('ss_live_your_api_key_here');

// Get product details
$product = $client->getProductDetails('012345678901');
echo "Product: " . $product['data']['name'] . "\n";

// Get current offers
$offers = $client->getCurrentOffers('012345678901');
foreach ($offers['data'] as $offer) {
    echo $offer['retailer'] . ": $" . $offer['price'] . "\n";
}

// Get price history
$history = $client->getPriceHistory(
    '012345678901',
    '2024-01-01',
    '2024-01-31'
);
```

## Laravel Integration

```php
// config/services.php
'shopsavvy' => [
    'api_key' => env('SHOPSAVVY_API_KEY'),
],

// In your controller
use ShopSavvy\Client;

class ProductController extends Controller
{
    public function show($barcode)
    {
        $client = new Client(config('services.shopsavvy.api_key'));
        $product = $client->getProductDetails($barcode);

        return view('product.show', compact('product'));
    }
}
```

## Features

- PSR-4 autoloading
- Laravel service provider
- Guzzle HTTP client
- Comprehensive error handling
- Support for PHP 8.0+
- Full PHPDoc documentation
