PHPackages                             getstream/getstream-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. getstream/getstream-php

ActiveLibrary[API Development](/categories/api)

getstream/getstream-php
=======================

PHP SDK for GetStream API

v7.4.0(2w ago)036.4k↑15.4%[3 PRs](https://github.com/GetStream/getstream-php/pulls)MITPHPPHP ^8.1CI passing

Since Aug 25Pushed 1w agoCompare

[ Source](https://github.com/GetStream/getstream-php)[ Packagist](https://packagist.org/packages/getstream/getstream-php)[ RSS](/packages/getstream-getstream-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (41)Versions (53)Used By (0)

GetStream PHP SDK
=================

[](#getstream-php-sdk)

A PHP SDK for the GetStream API.

Installation
------------

[](#installation)

Install via Composer:

```
composer require getstream/getstream-php
```

Migrating from stream-chat-php?
-------------------------------

[](#migrating-from-stream-chat-php)

If you are currently using [`stream-chat-php`](https://github.com/GetStream/stream-chat-php), we have a detailed migration guide with side-by-side code examples for common Chat use cases. See the [Migration Guide](docs/migration-from-stream-chat-php/README.md).

Configuration
-------------

[](#configuration)

Copy `.env.example` to `.env` and configure:

```
cp .env.example .env
```

Required environment variables:

```
STREAM_API_KEY=your_api_key_here
STREAM_API_SECRET=your_api_secret_here
STREAM_BASE_URL=https://chat.stream-io-api.com
```

Connection Pool Tuning
----------------------

[](#connection-pool-tuning)

```
$client = (new GetStream\ClientBuilder())
    ->apiKey($apiKey)
    ->apiSecret($apiSecret)
    ->maxConnsPerHost(5)   // default 5 (per-host concurrency cap, see runtime caveats)
    ->idleTimeout(55)      // default 55s (per-connection lifetime cap, see runtime caveats)
    ->connectTimeout(10)   // default 10s
    ->requestTimeout(30)   // default 30s
    ->build();
```

**Per-call timeout override:**

```
$response = $client->getHttpClient()->request(
    'GET', $url, $headers, null, ['timeout' => 2]
);
```

Per-call `curl` overrides replace (do not merge with) the client-level `curl` options, since Guzzle unions options shallowly. Only `['timeout' => N]` is documented for per-call use.

**Runtime caveats.** `maxConnsPerHost` and `idleTimeout` are enforced via libcurl's persistent multi-handle pool (`CURLMOPT_MAX_HOST_CONNECTIONS` and `CURLOPT_MAXLIFETIME_CONN`). They take effect only when the SDK client is reused across requests within a single PHP process: long-running runtimes such as Swoole, RoadRunner, ReactPHP, and CLI daemons. Instantiate the SDK client once and reuse it. Under PHP-FPM (and one-shot CLI scripts) the PHP process exits at the end of each request, so there is no cross-request pool to size; the per-call request and connect timeouts still apply. `idleTimeout` requires libcurl 7.80.0 (Nov 2021) or later; pooling still works without it on older builds, just without active lifetime cycling.

**Escape hatch:** Passing your own client via `->httpClient($mine)` skips all 4 knobs; your client is used as-is.

Code Generation
---------------

[](#code-generation)

Generate API methods from OpenAPI spec:

```
./generate.sh
```

Testing
-------

[](#testing)

Run tests:

```
# Run all tests
make test

# Run unit tests only
make test-unit

# Run integration tests (requires API credentials)
make test-integration
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
