PHPackages                             pbmengine/pbm-stream-sdk - 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. pbmengine/pbm-stream-sdk

ActiveLibrary[API Development](/categories/api)

pbmengine/pbm-stream-sdk
========================

SDK for using PBM Stream API

2.2.0(1y ago)01.7k↓50%MITPHPPHP ^7.4|^8.0

Since Nov 30Pushed 1y agoCompare

[ Source](https://github.com/pbmengine/pbm-stream-sdk)[ Packagist](https://packagist.org/packages/pbmengine/pbm-stream-sdk)[ Docs](https://github.com/pbmengine/pbm-stream-sdk)[ RSS](/packages/pbmengine-pbm-stream-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (9)Versions (31)Used By (0)

PBM Stream API SDK
==================

[](#pbm-stream-api-sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c1b0cb81d0dd19b0204de52295c83bb8ef9e9806d347bf62ce4aae70630ec849/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67656d7a696f2f70626d2d73747265616d2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pbmengine/pbm-stream-sdk)[![Total Downloads](https://camo.githubusercontent.com/8301756b64b4dc6c183adf3e448a5ccbf10a446d68d804e20c81f3db7658eee3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67656d7a696f2f70626d2d73747265616d2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pbmengine/pbm-stream-sdk)

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

[](#installation)

You can install the package via composer:

```
composer require pbmengine/pbm-stream-sdk
```

Usage
-----

[](#usage)

```
php artisan vendor:publish
```

Update the config file with url, project id and access key.

```
# in ./config/pbm-stream.php
return [
    'url' => env('PBM_STREAM_URL', ''),
    'project' => env('PBM_STREAM_PROJECT', ''),
    'access_key' => env('PBM_STREAM_ACCESS_KEY', '')
];
```

Now you can use the stream api.

```
# via helper
stream('logins')->record(['user' => 1, 'age' => 30]);

# via Facade
\Pbmengine\Stream\Facades\Stream::collection('logins')->record(['user' => 1, 'age' => 30]);
```

Available methods

```
# record event
stream('logins')->record(['user' => 1, 'age' => 30]);

# update event
stream('logins')->updateEvent('', ['age' => 30]);

# update several events with condition
# field is the condition field with value
# e.g. field is userId and value is 300
# stream('logins')->updateEvents('userId', 300, ['age' => 30]);
# means: update all events where userId is 300 and set age to 30
stream('logins')->updateEvents('field', 'value', ['age' => 30]);

# update events where you have several = conditions
stream('logins')->updateEventsWithConditions([
    'event' => 'items.purchased',
    'customerId' => 5
], [
    'age' => 30,
    'itemsPurchased' => true
]);

# delete event
stream('logins')->deleteEvent('');

# get project information
stream()->project();

# get project collections
stream()->collections();

# get collection informations
stream('logins')->collection();

# validate collection event
stream('logins')->validateEvent(['user' => 2, 'age' => 10]);

# test event to check if it's a valid event for any collection
# you do not need any collection for this request
stream()->testEvent(['user' => 2, 'age' => 10]);

# create collection index
# timestamp and _id are automatically indexed
stream('logins')->createIndex('');

# drop collection index
stream('logins')->dropIndex('');

# add new property key to collection
# - field is the name of the property
# - defaultValue is the default value for existing documents
# - type is the type of the property (string, bool, num, array)
stream('logins')->addPropertyKey(, , );

# delete property key from collection
stream('logins')->deletePropertyKey();

# rename property key in collection
stream('logins')->renamePropertyKey(, );

# query options
$response = stream('logins')
    ->query()
    ->select(['_id', 'event', 'itemPrice'])
    ->where('a', '=', 2)
    ->whereIn('', ['array', '...'])
    ->orWhere('b', '>', 6)
    ->timeFrame('', '')
    ->timeFrame(TimeFrame::THIS_DAYS, 5)
    ->timeFrame(TimeFrame::PREVIOUS_DAYS, 6)
    ->groupBy('') // (['field a', 'field b'])
    ->orderBy('', 'asc') // second parameter is optional, default is asc
    ->orderByDesc('') // order desc
    ->count(); // sum(field) | avg(field) | max(field) | min(field) | countUnique(field) | selectUnique(field)

// get events
$response = stream('pages')
    ->query()
    ->where('event', '=', 'page.viewed')
    ->orWhere('event', '=', 'login.viewed')
    ->take(10)
    ->orderByDesc('timestamp')
    ->get();

// get events with pagination
$response = stream('pages')
    ->query()
    ->where('event', '=', 'page.viewed')
    ->orderByDesc('timestamp')
    ->paginate(10, 1); // per page 10 events on page 1

# complex queries
# for more complex queries use the aggregate function
stream('pages')
    ->query()
    ->aggregate([
        ['$match' => ['event' => 'pageViewed']]
    ]);
```

Responses

Responses are always Laravel Http Client Responses!

```
# get() method
$response = stream('pages')->take(1)->get()->json();
```

```
{
  "data": [
        {
            "_id": "61b28877a57f17655163cea2",
            "event": "video.started",
            "userId": 107,
            "customerId": 772,
            "hasContract": false,
            "customerAge": 34,
            "hasChildren": false,
            "persona": "mf",
            "timestamp": "2021-12-09T22:51:34.000000Z",
            "clientDevice": "desktop",
            "clientOsName": "Mac",
            "clientOsVersion": "10.15",
            "clientType": "browser",
            "clientName": "Chrome",
            "clientVersion": "95.0",
            "clientIsMobile": false,
            "clientIsBot": false
        }
  ]
}
```

```
# paginate() method
$response = stream('pages')->paginate(1)->json();
```

```
{
    "data": [
        {
            "_id": "61b28877a57f17655163cea2",
            "event": "video.started",
            "userId": 107,
            "customerId": 772,
            "hasContract": false,
            "customerAge": 34,
            "hasChildren": false,
            "persona": "mf",
            "timestamp": "2021-12-09T22:51:34.000000Z",
            "clientDevice": "desktop",
            "clientOsName": "Mac",
            "clientOsVersion": "10.15",
            "clientType": "browser",
            "clientName": "Chrome",
            "clientVersion": "95.0",
            "clientIsMobile": false,
            "clientIsBot": false
        }
    ],
    "meta": {
        "total": 304,
        "current_page": 1,
        "last_page": 304,
        "per_page": 1,
        "total_pages": 304,
        "count": 1,
        "execution_time": 0.05970406532287598
    }
}
```

```
# count(), max(), min(), sum(), avg() method
$response = stream('pages')->avg('customerAge')->json();
```

```
{
  "result": 50.18421052631579
}
```

```
# testing events
$response = stream()->testEvent(['event' => 'test', '2983' => 12, 'test' => null])->json();
```

```
{
    "status": "failed",
    "errors": {
        "2983": "2983 must only have alphabetical characters",
        "test": "test must only be a string, boolean or numeric value"
    }
}
```

```
# validate events for collection
$response = stream('purchases')->validateEvent(['event' => 'test'])->json();
```

```
{
    "status": "failed",
    "errors": {
        "userId": "num",
        "itemId": "num",
        "itemName": "string",
        "itemQuantity": "num",
        "itemInStock": "bool"
    }
}
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Stefan Riehl](https://github.com/stefanriehl)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance47

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~42 days

Recently: every ~132 days

Total

30

Last Release

395d ago

Major Versions

1.4.2 → 2.0.02023-12-07

PHP version history (3 changes)1.0.0PHP ^8.0

1.1.1PHP ^7.4||^8.0

1.3.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50110897?v=4)[PBM Personal Business Machine AG](/maintainers/pbmengine)[@pbmengine](https://github.com/pbmengine)

---

Top Contributors

[![stefanriehl](https://avatars.githubusercontent.com/u/50109920?v=4)](https://github.com/stefanriehl "stefanriehl (7 commits)")

---

Tags

pbmpbm-stream-sdk

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pbmengine-pbm-stream-sdk/health.svg)

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

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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