composer require getstream/getstream-php:^6.0.0Installation
This SDK is the server half of your integration. Your users read and write feeds from your app with a client SDK, and anything that needs a connected user or a live WebSocket belongs there: the state layer, device push registration, and client-side error handling. See the client-side overview for what lives there. Token signing stays on this side, because it needs your API secret.
Composer
This installs the latest 6.x PHP SDK with typed generated models and up-to-date Feeds API coverage.
Use the latest major version that is compatible with your app.
Check getstream-php releases and update the constraint if a newer major is available.
GitHub repository: https://github.com/GetStream/getstream-php. Feel free to submit bug reports and feature requests.
The package is tested against these environments:
- PHP 8.1+
- PHP 8.2+
- PHP 8.3+
To create a client, you'll need your API key and secret. Both of them can be found in your Stream Dashboard.
The SDK has support for all Stream's producs: chat, video and feeds.
$clientis used for operations shared among all products (such as user management)$feedsClientis used for feed operations
<?php
require_once 'vendor/autoload.php';
use GetStream\ClientBuilder;
$this->client = (new ClientBuilder())
->apiKey($this->apiKey)
->apiSecret($this->apiSecret)
->build();
$this->feedsClient = (new ClientBuilder())
->apiKey($this->apiKey)
->apiSecret($this->apiSecret)
->buildFeedsClient();
// or
$client = (new ClientBuilder())
->apiKey($apiKey)
->apiSecret($apiSecret)
->build();
$feedsClient = (new ClientBuilder())
->apiKey($apiKey)
->apiSecret($apiSecret)
->buildFeedsClient();Connection pool and timeouts
The SDK uses Guzzle with a libcurl connection pool and keep-alive enabled by default. Tune it on the ClientBuilder:
| Method | Default | Description |
|---|---|---|
requestTimeout | 30 | Per-request timeout in seconds. |
maxConnsPerHost | 5 | Maximum concurrent connections per host. |
idleTimeout | 55 | Maximum lifetime of a pooled connection in seconds. |
connectTimeout | 10 | TCP + TLS handshake timeout in seconds. |
$feedsClient = (new ClientBuilder())
->apiKey($apiKey)
->apiSecret($apiSecret)
->maxConnsPerHost(10)
->idleTimeout(55)
->connectTimeout(10)
->requestTimeout(30)
->buildFeedsClient();To take full control of the HTTP stack, pass your own client with ->httpClient($client). When set, the pool options above are not applied.
Connection pooling persists across requests only in long-running runtimes (Swoole, RoadRunner, ReactPHP, CLI workers). Under PHP-FPM the process ends after each request, so the per-request timeouts still apply but connections are not reused across requests.
Migration Guide: v1.0.0 to v2.0.0
Version 2.0.0 introduces breaking changes to improve type safety and IDE support. Here are the main changes:
Array Access → Object Properties
Before (v1.0.0):
$activities = $response->getData()->activities;
$id = $activities[0]['id']; // Array access
$reactions = $activities[0]['own_reactions']; // Snake caseAfter (v2.0.0):
$activities = $response->getData()->activities;
$id = $activities[0]->id; // Object property access
$reactions = $activities[0]->ownReactions; // Camel caseKey Changes
-
Array properties are now objects: Arrays containing model objects (like
activities,aggregatedActivities,followers, etc.) are automatically parsed into typed objects. -
CamelCase properties: All properties now use camelCase instead of snake_case:
own_reactions→ownReactionsreaction_count→reactionCountupdated_at→updatedAt
-
Nested object access: Nested objects are accessed via properties, not arrays:
$reaction['user']['id']→$reaction->user->id
-
Method signatures: Some methods now take direct parameters instead of arrays:
listDevices(['user_id' => $id])→listDevices($id)
Migration Steps
- Update your code to use object property access (
->) instead of array access ([]) - Replace snake_case property names with camelCase
- Update method calls to use direct parameters where applicable
- Test thoroughly, especially code that accesses nested properties
For more details, see the release notes.