PHPackages                             larahook/simple-centrifugo - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. larahook/simple-centrifugo

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

larahook/simple-centrifugo
==========================

Connection and subscription tokens for centrifugo

v0.0.13(1mo ago)22.5kMITPHPPHP ^8.0

Since Mar 26Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Mishanki/simple-centrifugo)[ Packagist](https://packagist.org/packages/larahook/simple-centrifugo)[ Docs](https://github.com/Mishanki/simple-centrifugo)[ RSS](/packages/larahook-simple-centrifugo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (14)Used By (0)

Connection and subscription tokens for centrifugo
=================================================

[](#connection-and-subscription-tokens-for-centrifugo)

Install
-------

[](#install)

```
composer require larahook/simple-centrifugo

```

Driver
------

[](#driver)

Add `centrifugo` connection with `simple-centrifugo` driver to `config/broadcasting.php`

```
'connections' => [
    'centrifugo' => [
        'driver' => 'simple-centrifugo',
        'token_hmac_secret_key' => env('CENTRIFUGO_TOKEN_HMAC_SECRET_KEY', ''),
        'api_key' => env('CENTRIFUGO_API_KEY', ''),
        'url' => env('CENTRIFUGO_URL', 'http://localhost:8000'), // centrifugo api url
        'verify' => env('CENTRIFUGO_VERIFY', false), // Verify host ssl if centrifugo uses this
        'ssl_key' => env('CENTRIFUGO_SSL_KEY', null), // Self-Signed SSl Key for Host (require verify=true)
    ],
]
```

Usage
-----

[](#usage)

### Get tokens for client

[](#get-tokens-for-client)

- Add `SimpleCentrifugo` trait to your class
- Use method `getConnectionToken` for get connection token
- And use method `getSubscriptionToken` for get subscription tokens

```
use Carbon\Carbon;
use Larahook\SimpleCentrifugo\Trait\SimpleCentrifugo;

class ChannelService
{
    use SimpleCentrifugo;

    /**
     * @param int $userId
     * @param Carbon $exp
     *
     * @return array
     */
    public function getConnToken(int $userId, Carbon $exp): array
    {
        return $this->getConnectionToken($userId, $exp);
    }

    /**
     * @param int $userId
     * @param array $channels
     * @param Carbon $exp
     *
     * @return array
     */
    public function getSubsToken(int $userId, array $channels, Carbon $exp): array
    {
        return $this->getSubscriptionToken($userId, $channels, $exp);
    }
}
```

### Event example

[](#event-example)

Push message to centrifugo channel via laravel events

```
namespace App\Events;

use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Auth;

class PersonalEvent implements ShouldBroadcastNow
{
    use Dispatchable;
    use SerializesModels;

    /**
     * @param array $message
     */
    public function __construct(public array $message) {}

    /**
     * Get the channels the event should broadcast on.
     *
     * @return array
     */
    public function broadcastOn()
    {
        return ['personal:#'.Auth::id()];
    }

    public function broadcastAs()
    {
        return 'PersonalEvent';
    }
}
```

### Event execute

[](#event-execute)

```
PersonalEvent::dispatch(['info']);
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Total

13

Last Release

45d ago

PHP version history (2 changes)v0.0.1PHP ^7.4|^8.0

v0.0.4PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5513299b5470b3e7c5f0582ce7a7f941528a3ad48321429e375f1645d28a389e?d=identicon)[Mishanki](/maintainers/Mishanki)

---

Top Contributors

[![Mishanki](https://avatars.githubusercontent.com/u/11581729?v=4)](https://github.com/Mishanki "Mishanki (2 commits)")

---

Tags

centrifugoconnectionsubscriptiontokentokencentrifugoconnection tokensubscription token

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/larahook-simple-centrifugo/health.svg)

```
[![Health](https://phpackages.com/badges/larahook-simple-centrifugo/health.svg)](https://phpackages.com/packages/larahook-simple-centrifugo)
```

###  Alternatives

[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)[oleh-ozimok/php-centrifugo

PHP client for Centrifugo real-time messaging server

39511.1k1](/packages/oleh-ozimok-php-centrifugo)[dirape/token

Unique Token Generator For Laravel

28277.4k2](/packages/dirape-token)[laracomponents/centrifuge-broadcaster

Centrifuge broadcaster for laravel &gt;= 5.3

227.5k](/packages/laracomponents-centrifuge-broadcaster)[shetabit/token-builder

Laravel Token Builder

236.7k](/packages/shetabit-token-builder)[kevinsimard/laravel-cookieless-session

Laravel middleware to start a cookieless session

1417.0k](/packages/kevinsimard-laravel-cookieless-session)

PHPackages © 2026

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