PHPackages                             socketbus/socketbus-php - 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. socketbus/socketbus-php

ActiveLibrary

socketbus/socketbus-php
=======================

v1.0.1(5y ago)0361PHPPHP &gt;=5.3.0

Since Jan 6Pushed 5y agoCompare

[ Source](https://github.com/SocketBus/socketbus-php)[ Packagist](https://packagist.org/packages/socketbus/socketbus-php)[ RSS](/packages/socketbus-socketbus-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (1)

SocketBus PHP Library
=====================

[](#socketbus-php-library)

The SocketBus PHP Library

#### Getting Started

[](#getting-started)

1. **Create an account** -
2. **Minimum requirements** -
3. **Install the library** - ```
    composer require socketbus/socketbus-php
    ```
4. **Using the library** -

Create a SocketBus instance
---------------------------

[](#create-a-socketbus-instance)

```
require 'vendor/autoload.php';

use SocketBus\SocketBus;

$config = [
    'app_id' => 's-1-J2PCu8g8sAejZeXx',
    'secret' => 'cdKBpcruwYQ96kvIaYiorbTFxRDCbVfj'
];

$socketBus = new SocketBus($config);
```

###### End-to-End Encryption

[](#end-to-end-encryption)

To ensure that your data is secure, you can enable End-to-end encryption under Application &gt; Settings. This setting in combination with the option `custom_encryption_key` encrypts the payload and decrypts in the client when an authenticated user receives a encrypted payload.

```
$config = [
    'app_id' => 's-1-J2PCu8g8sAejZeXx',
    'secret' => 'cdKBpcruwYQ96kvIaYiorbTFxRDCbVfj',
    'custom_encryption_key' => 'my-unique-key'
];
```

Authentication
--------------

[](#authentication)

##### Defining the channel type

[](#defining-the-channel-type)

```
$channelName = $request->channel_name;

if ($socketBus->isChannelPrivate($channelName)) {
    // The channel is private
}
if ($socketBus->isChannelPresence($channelName)) {
    // The channel is presence
}
if ($socketBus->isChannelPublic($channelName)) {
    // The channel is public
}
```

##### Private Authentication

[](#private-authentication)

```
$socketId = $request->socket_id;
$channelName = $request->channel_name;

if (/** verifies if user can access the request channel */) {
    // returns the token to the client
    return [
        'auth' => $socketbus->auth($socketId, $channelName)
    ];
}
```

##### Presence Authentication

[](#presence-authentication)

```
$socketId = $request->socket_id;
$channelName = $request->channel_name;
$userId = /** gets the current user id */;

if (/** verifies if user can access the request channel */) {
    // returns the data
    return $socketbus->authPresence($socketId, $channelName, $userId, true);
}
```

Broadcasting
------------

[](#broadcasting)

```
$payload = [
    'type' => 'cupcake',
    'flavor' => 'sweet'
];

$sockebus->broadcast('food-observer', 'new-food', $payload);
```

Resources
---------

[](#resources)

[API Docs](https://socketbus.com/docs) - Check-out the full documentation

Related Projects
----------------

[](#related-projects)

[SocketBus Laravel Library](https://github.com/SocketBus/socketbus-laravel) - Laravel library

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Total

2

Last Release

1958d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/29dedbf00247702e73eccc8e6c24d002157088c9a0b8cb146026489aa159f53a?d=identicon)[valterlorran](/maintainers/valterlorran)

---

Top Contributors

[![valterlorran](https://avatars.githubusercontent.com/u/1234758?v=4)](https://github.com/valterlorran "valterlorran (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/socketbus-socketbus-php/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[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)
