> ## Documentation Index
> Fetch the complete documentation index at: https://learn.biq.li/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP and Laravel

> Track trusted conversions with the Biqli PHP SDK.

The `biqli/sdk` package supports PHP 8.1 or newer and uses a secret workspace API key.

## Install

```bash theme={null}
composer require biqli/sdk
```

Add the key to your server environment:

```bash theme={null}
BIQLI_API_KEY=biqli_xxxxxxxxxxxxxxxxxxxxxxxx
```

## Create a reusable client

```php theme={null}
use Biqli\Sdk\Biqli;

$biqli = new Biqli($_ENV['BIQLI_API_KEY'], [
    'clientName' => 'acme-laravel',
    'clientVersion' => '1.0.0',
]);
```

In Laravel, bind this client as a singleton in a service provider rather than creating it for every event.

## Track a lead

```php theme={null}
$lead = $biqli->track->lead([
    'clickId' => $request->cookie('bq_id'),
    'eventId' => 'signup:' . $user->getKey(),
    'eventName' => 'Signed up',
    'customerExternalId' => (string) $user->getKey(),
    'customerName' => $user->name,
    'customerEmail' => $user->email,
]);
```

## Track a sale

```php theme={null}
$sale = $biqli->track->sale([
    'customerExternalId' => (string) $user->getKey(),
    'amount' => 4999,
    'currency' => 'usd',
    'paymentProcessor' => 'stripe',
    'invoiceId' => $invoice->id,
]);
```

## Handle errors

```php theme={null}
use Biqli\Sdk\Exceptions\BiqliException;

try {
    $biqli->track->sale($input);
} catch (BiqliException $error) {
    logger()->error('Biqli tracking failed', [
        'code' => $error->errorCode,
        'status' => $error->status,
        'request_id' => $error->requestId,
        'retryable' => $error->retryable,
        'attempts' => $error->attempts,
    ]);
}
```

Do not log the API key or the entire unfiltered payload.

The SDK retries bounded temporary failures. Stable event and invoice identifiers make retries safe across workers and deployments.

See the complete [PHP SDK reference](/docs/api-reference/sdks/php).
