PHPackages                             get-stream/stream - 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. get-stream/stream

ActiveLibrary[API Development](/categories/api)

get-stream/stream
=================

A PHP client for Stream (https://getstream.io)

v8.0.0(2mo ago)1451.3M—1.9%338BSD-3-ClausePHPPHP &gt;=8.0CI passing

Since May 19Pushed 2mo ago39 watchersCompare

[ Source](https://github.com/GetStream/stream-php)[ Packagist](https://packagist.org/packages/get-stream/stream)[ Docs](https://getstream.io)[ RSS](/packages/get-stream-stream/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (76)Used By (8)

Official PHP SDK for [Stream Feeds](https://getstream.io/activity-feeds/)
=========================================================================

[](#official-php-sdk-for-stream-feeds)

[![build](https://github.com/GetStream/stream-php/workflows/build/badge.svg)](https://github.com/GetStream/stream-php/actions) [![Latest Stable Version](https://camo.githubusercontent.com/b0e61280e4de2335edb96aa5b8d8332f127c41e0fe626992ea366789fe7a0ee8/68747470733a2f2f706f7365722e707567782e6f72672f6765742d73747265616d2f73747265616d2f762f737461626c65)](https://packagist.org/packages/get-stream/stream)

 [![](./assets/logo.svg)](./assets/logo.svg)

 Official PHP API client for Stream Feeds, a web service for building scalable newsfeeds and activity streams.
 [**Explore the docs »**](https://getstream.io/activity-feeds/docs/?language=php)

 [Laravel Feeds Library](https://github.com/GetStream/stream-laravel) · [Report Bug](https://github.com/GetStream/stream-php/issues) · [Request Feature](https://github.com/GetStream/stream-php/issues)

📝 About Stream
--------------

[](#-about-stream)

> > 💡 Note: this is a library for the **Feeds** product. The Chat SDKs can be found [here](https://getstream.io/chat/docs/).

You can sign up for a Stream account at our [Get Started](https://getstream.io/activity-feeds/) page.

You can use this library to access Feeds API endpoints server-side.

For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries ([docs](https://getstream.io/activity-feeds/docs/?language=php)).

> 💡 Note: there is also a higher level [Laravel integration](https://github.com/getstream/stream-laravel) which hooks into the Eloquent ORM.

⚙️ Installation
---------------

[](#️-installation)

```
$ composer require get-stream/stream
```

Composer will install our latest version automatically.

### PHP compatibility

[](#php-compatibility)

Current releases require PHP `8.0` or higher, and depends on Guzzle version `^7.5.0`.

If you need to use the client with an old PHP or earlier versions of Guzzle, you can grab an earlier version of this package, for example:

```
$ composer require get-stream/stream:"~5.0.0"
```

See the [action](.github/workflows/ci.yml) for details of how it is built and tested against different PHP versions.

📚 Documentation
---------------

[](#-documentation)

Our full documentation for this package is available at .

✨ Getting started
-----------------

[](#-getting-started)

First, [signup here](https://getstream.io/dashboard/) for a free account and grab your API key and secret.

Initiating a Client and a Feed object:

```
// Instantiate a new client, find your API keys in the dashboard.
$client = new GetStream\Stream\Client('YOUR_API_KEY', 'YOUR_API_SECRET');

// Instantiate a feed object
$userFeed = $client->feed('user', '1');

// If you want, you can set a custom http handler
$handler = new \GuzzleHttp\HandlerStack();
$stack->push(Middleware::mapRequest(function (RequestInterface $r) {
    echo 'Sending request to Stream Feeds API: ' . $r->getUri() . PHP_EOL;
    return $r;
}));
$client->setCustomHttpHandler($handler);
```

By default, the Client will target the GetStream REST API at `stream-io-api.com/api`. If you want to change this for some reason you can set the `STREAM_BASE_URL` environment variable.

Activities in a feed:

```
// Create a new activity
$data = [
    'actor' => '1',
    'verb' => 'like',
    'object' => '3',
    'foreign_id' => 'like:42',
];

$response = $userFeed->addActivity($data);

// The response will include Stream's internal ID:
// {"id": "e561...", "actor": "1", ...}

// Get the latest activities for this user's personal feed, based on who they are following.
$response = $userFeed->getActivities();

// Get activities directly by their ID or combination of foreign ID and time.
$response = $client->getActivitiesById(['74b9e88a-a684-4197-b30c-f5e568ef9ae2', '965f7ba5-8f1d-4fd1-a9ee-22d1a2832645']);
$response = $client->getActivitiesByForeignId(['fid:123', '2006-01-02T15:04:05.000000000'], ['fid:456', '2006-01-02T16:05:06.000000000']);

// The response will be the json decoded API response.
// {"duration": 45ms, "next": "/api/v1.0/feed/...", "results": [...]}

// Remove an activity by its ID
$userFeed->removeActivity('e561de8f-00f1-11e4-b400-0cc47a024be0');

// To remove activities by their foreign_id, set the "foreign id" flag to true.
$userFeed->removeActivity('like:42', true);
```

Following/follower relations of a feed:

```
// When user 1 starts following user 37's activities
$userFeed->follow('user', '37');

// When user 1 stops following user 37's activities
$userFeed->unfollow('user', '37');

// Retrieve followers of a feed
$userFeed->followers();

// Retrieve feeds followed by $userFeed
$userFeed->following();
```

Advanced activity operations:

```
// Create a bit more complex activity with custom fields
$data = [
    'actor' => 1,
    'verb' => 'run',
    'object' => 1,
    'foreign_id' => 'run:42',

    // Custom fields:
    'course' => [
        'name'=> 'Golden Gate park',
        'distance'=> 10,
    ],
    'participants' => ['Thierry', 'Tommaso'],
    'started_at' => new DateTime('now', new DateTimeZone('Pacific/Nauru'),
];

// Add an activity and push it to other feeds too using the `to` field
$data = [
    'actor' => '1',
    'verb' => 'like',
    'object' => '3',
    'to' => [
        'user:44',
        'user:45',
    ],
];

$userFeed->addActivity($data);

// Batch adding activities
$activities = [
    ['actor' => '1', 'verb' => 'tweet', 'object' => '1'],
    ['actor' => '2', 'verb' => 'like', 'object' => '3'],
];

$userFeed->addActivities($activities);
```

Advanced batching:

```
// Batch operations (batch activity add, batch follow)
$batcher = $client->batcher();

// Add one activity to many feeds
$activity = ['actor' => '1', 'verb' => 'tweet', 'object' => '1'];
$feeds = ['user:1', 'user:2'];

$batcher->addToMany($activity, $feeds);

// Create many follow relations
$follows = [
    ['source' => 'user:b1', 'target' => 'user:b2'],
    ['source' => 'user:b1', 'target' => 'user:b3'],
];

$batcher->followMany($follows);
```

Generating tokens for client-side usage:

```
// Generating a user token
$userToken = $client->createUserSessionToken("the-user-id");
```

RateLimits:

If your app hits a ratelimit, a StreamFeedException is thrown. You can get additional info by catching the exception and calling the following methods:

```
try {
    $client->updateActivity($activity);
}catch(StreamFeedException $e){
    $limit = $e->getRateLimitLimit();
    $remaining = $e->getRateLimitRemaining();
    $reset = $e->getRateLimitReset(); // a unix timestamp
}
```

Reactions:

The reactions module has the following methods.

```
- add(string $kind, string $activityId, string $userId, array $data=null, array $targetFeeds=null)
- addChild(string $kind, string $parentId, string $userId, array $data=null, array $targetFeeds=null)
- delete(string $reactionId)
- filter(string $lookupField, string $lookupValue, string $kind=null, array $params=null)
- get(string $reactionId)
- update(string $reactionId, array $data=null, array $targetFeeds=null)

```

Also see documention on the [reactions endpoint](https://getstream.io/docs_rest/#reactions)

```
$reaction = $client->reactions()->add('like', $activity_id, 'bob');

$bob_likes = $client->reactions()->filter('user_id', 'bob', 'like');

$client->reactions()->delete($reaction['id']);
```

Users:

The users module has the following methods.

```
- add(string $userId, array $data=null, bool $getOrCreate=false)
- createReference(string $userId)
- delete(string $userId)
- get(string $userId)
- update(string $userId, array $data=null)

```

Also see documention on the [users endpoint](https://getstream.io/docs/php/#users_introduction)

```
$user = $client->users()->add('42');

$user =  $client->users()->update('42', array('name' => 'Arthur Dent');

$client->users()->delete('42');
```

Again, our full documentation with all options and methods, is available at .

☯️ Framework integration
------------------------

[](#️-framework-integration)

### Laravel

[](#laravel)

There's a higher level integration with [Laravel](https://laravel.com) called [`get-stream/stream-laravel`](https://github.com/getstream/stream-laravel). The `stream-laravel` integration helps you to hook into the Laravel's Eloquent ORM to sync data to Stream.

✍️ Contributing
---------------

[](#️-contributing)

Project is licensed under the [BSD 3-Clause](LICENSE).

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our [license file](./LICENSE) for more details.

🧑‍💻 We are hiring!
------------------

[](#‍-we-are-hiring)

We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via [Stream's website](https://getstream.io/team/#jobs).

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity56

Moderate usage in the ecosystem

Community37

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~323 days

Total

67

Last Release

66d ago

Major Versions

3.0.2 → 4.0.02019-11-25

4.1.1 → 5.0.02021-03-26

5.2.0 → 6.0.02022-08-29

6.0.0 → v7.0.02023-02-21

v7.1.0 → v8.0.02026-03-13

PHP version history (7 changes)1.0.0PHP &gt;=5.4.0

2.0.0PHP &gt;=5.4

2.2.1PHP &gt;=5.5

4.0.0PHP &gt;=7.2

5.0.0PHP &gt;=7.3

6.0.0PHP &gt;=7.4

v7.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/88735?v=4)[Tommaso Barbugli](/maintainers/tbarbugli)[@tbarbugli](https://github.com/tbarbugli)

---

Top Contributors

[![tbarbugli](https://avatars.githubusercontent.com/u/88735?v=4)](https://github.com/tbarbugli "tbarbugli (150 commits)")[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (80 commits)")[![pterk](https://avatars.githubusercontent.com/u/188764?v=4)](https://github.com/pterk "pterk (36 commits)")[![ferhatelmas](https://avatars.githubusercontent.com/u/648018?v=4)](https://github.com/ferhatelmas "ferhatelmas (29 commits)")[![tschellenbach](https://avatars.githubusercontent.com/u/265409?v=4)](https://github.com/tschellenbach "tschellenbach (12 commits)")[![iandouglas](https://avatars.githubusercontent.com/u/168030?v=4)](https://github.com/iandouglas "iandouglas (9 commits)")[![ruggi](https://avatars.githubusercontent.com/u/1081051?v=4)](https://github.com/ruggi "ruggi (8 commits)")[![peterdeme](https://avatars.githubusercontent.com/u/19969687?v=4)](https://github.com/peterdeme "peterdeme (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![dwightgunning](https://avatars.githubusercontent.com/u/454042?v=4)](https://github.com/dwightgunning "dwightgunning (6 commits)")[![JimmyPettersson85](https://avatars.githubusercontent.com/u/953852?v=4)](https://github.com/JimmyPettersson85 "JimmyPettersson85 (5 commits)")[![neeckeloo](https://avatars.githubusercontent.com/u/1768645?v=4)](https://github.com/neeckeloo "neeckeloo (3 commits)")[![olix21](https://avatars.githubusercontent.com/u/3217330?v=4)](https://github.com/olix21 "olix21 (2 commits)")[![kevin-lot](https://avatars.githubusercontent.com/u/5575659?v=4)](https://github.com/kevin-lot "kevin-lot (1 commits)")[![bdandy](https://avatars.githubusercontent.com/u/7849405?v=4)](https://github.com/bdandy "bdandy (1 commits)")[![dirkaholic](https://avatars.githubusercontent.com/u/164408?v=4)](https://github.com/dirkaholic "dirkaholic (1 commits)")[![ErikAugust](https://avatars.githubusercontent.com/u/3004714?v=4)](https://github.com/ErikAugust "ErikAugust (1 commits)")[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (1 commits)")[![andytruong](https://avatars.githubusercontent.com/u/181753561?v=4)](https://github.com/andytruong "andytruong (1 commits)")[![marco-ulge](https://avatars.githubusercontent.com/u/54494803?v=4)](https://github.com/marco-ulge "marco-ulge (1 commits)")

---

Tags

activity-feedfeedgetstream-ionews-feednotification-feedphpstreamtimelinestreamfeedlynewsfeed

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/get-stream-stream/health.svg)

```
[![Health](https://phpackages.com/badges/get-stream-stream/health.svg)](https://phpackages.com/packages/get-stream-stream)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[get-stream/stream-chat

A PHP client for Stream Chat (https://getstream.io/chat/)

301.8M2](/packages/get-stream-stream-chat)[agence104/livekit-server-sdk

Server-side SDK for LiveKit.

79189.9k1](/packages/agence104-livekit-server-sdk)[packbackbooks/lti-1p3-tool

A library used for building IMS-certified LTI 1.3 tool providers in PHP.

51438.3k2](/packages/packbackbooks-lti-1p3-tool)[get-stream/stream-laravel

Build newsfeeds and activity feeds on Laravel using getstream.io

328327.1k](/packages/get-stream-stream-laravel)[hoels/app-store-server-library-php

The PHP server library for the App Store Server API and App Store Server Notifications.

44162.2k](/packages/hoels-app-store-server-library-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
