composer require getstream/getstream-php:^2.0.0Installation
Composer
This will install version 2.0.0, which includes improved type safety and object property access.
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();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.