Installation

Composer

composer require getstream/getstream-php:^2.0.0

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.

  • $client is used for operations shared among all products (such as user management)
  • $feedsClient is 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 case

After (v2.0.0):

$activities = $response->getData()->activities;
$id = $activities[0]->id; // Object property access
$reactions = $activities[0]->ownReactions; // Camel case

Key Changes

  1. Array properties are now objects: Arrays containing model objects (like activities, aggregatedActivities, followers, etc.) are automatically parsed into typed objects.

  2. CamelCase properties: All properties now use camelCase instead of snake_case:

    • own_reactionsownReactions
    • reaction_countreactionCount
    • updated_atupdatedAt
  3. Nested object access: Nested objects are accessed via properties, not arrays:

    • $reaction['user']['id']$reaction->user->id
  4. Method signatures: Some methods now take direct parameters instead of arrays:

    • listDevices(['user_id' => $id])listDevices($id)

Migration Steps

  1. Update your code to use object property access (->) instead of array access ([])
  2. Replace snake_case property names with camelCase
  3. Update method calls to use direct parameters where applicable
  4. Test thoroughly, especially code that accesses nested properties

For more details, see the release notes.

© Getstream.io, Inc. All Rights Reserved.