# PHP

`talaria/talaria` **3.0.3** is the official PHP SDK. PHP **8.1+**. Building Silverstripe? Install [`talaria/silverstripe`](https://docs.newtalaria.com/sdk/silverstripe.md). Building Laravel? Install [`talaria/laravel`](https://docs.newtalaria.com/sdk/laravel.md).

## Install

```bash
composer require talaria/talaria:^3.0
```

## Initialise

```php
use Talaria\Talaria;

Talaria::init([
    'apiKey' => getenv('TALARIA_API_KEY'),
    'release' => getenv('TALARIA_RELEASE') ?: null,
    'minLevel' => 'warning',
]);
```

`TALARIA_API_KEY` is a secret `tal_sk_<env>_<cell>_…` key. A missing or bad key never throws: Talaria is disabled, every call is a no-op, and one warning is logged (at most the first eight key characters). A publishable `tal_pk_` key logs one warning: ingest and `POST /v1/flags/evaluate` work, but monitors, releases, and `GET /v1/flags` need a secret key.

Leave `url` unset and the SDK sends to `https://ingest-<cell>.newtalaria.com` from the key.

## Verify

```php
\Talaria\Talaria::captureException(new \RuntimeException('Talaria test error'));
```

Run this once, then open **Issues** in the [dashboard](https://one.newtalaria.com). The test error shows as a new issue in the key's environment. Nothing there? See [fail-safe](https://docs.newtalaria.com/get-started/fail-safe.md).

## Next

See [configuration](https://docs.newtalaria.com/sdk/php/configuration.md), [errors](https://docs.newtalaria.com/sdk/php/errors.md), and [tracing](https://docs.newtalaria.com/sdk/php/tracing.md). For container logs on SiteHost, also follow the [SiteHost guide](https://docs.newtalaria.com/guides/collectors/sitehost.md).
