# Installation

Install version 2 of the SurrealDB PHP SDK with Composer, including a PSR-18 HTTP client.

Version 2 of the PHP SDK is installed with [Composer](https://getcomposer.org/download/). It requires PHP `8.4` or later.

## Install the SDK

Version 2 is an alpha release, so you need to request the exact version. Composer will not select it under the default `stable` minimum stability.

```bash
composer require surrealdb/surrealdb.php:2.0.0-alpha.1
```

If you want Composer to keep tracking alpha releases, set the stability flag instead:

```bash
composer require "surrealdb/surrealdb.php:^2.0@alpha"
```

## Add an HTTP client

The HTTP engine uses [PSR-18](https://www.php-fig.org/psr/psr-18/) and [PSR-17](https://www.php-fig.org/psr/psr-17/) interfaces rather than a built-in client. Install a compatible client and factory implementation, plus discovery so the SDK can find them automatically.

```bash
composer require guzzlehttp/guzzle php-http/discovery
```

> [!NOTE]
> The WebSocket engine uses PHP's native stream functions and needs no extra packages. You only need a PSR-18 client when connecting over `http://` or `https://`, or when using import and export.

## Import the SDK

Include the Composer autoloader, then import the classes you need from the `SurrealDB\SDK` namespace.

```php
require __DIR__ . '/vendor/autoload.php';

use SurrealDB\SDK\Surreal;
use SurrealDB\SDK\Connection\ConnectOptions;
use SurrealDB\SDK\Auth\RootAuth;
use SurrealDB\SDK\Types\RecordId;
use SurrealDB\SDK\Types\Table;
```

## Next steps

- [Getting started](/docs/reference/php/versions/v2-alpha.md) to connect and run your first queries
- [Connecting to SurrealDB](/docs/reference/php/v2/concepts/connecting-to-surrealdb.md) for connection options and reconnection
- [Migration guide](/docs/reference/php/v2/migration.md) if you are coming from v1
