PHPackages                             zavrik/laravel-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. zavrik/laravel-centrifugo

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

zavrik/laravel-centrifugo
=========================

0.3.1(12mo ago)0995MITPHPPHP ^8.0

Since Nov 5Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/Zavrik94/Laravel-Centrifugo)[ Packagist](https://packagist.org/packages/zavrik/laravel-centrifugo)[ RSS](/packages/zavrik-laravel-centrifugo/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

Laravel-Centrifugo For Docker
=============================

[](#laravel-centrifugo-for-docker)

This package is an easier way for use [Centrifugo v3](https://centrifugal.dev/) with [Laravel Framework](https://laravel.com/) and [Docker](https://www.docker.com/). It realises proxy connections inside docker for trigger events when we have some data in WebSocket Connection.

### Install

[](#install)

1. Copy to .env

```
CENTRIFUGO_APP_DOCKER_URL=http://:
CENTRIFUGO_PROXY_DOCKER_URL=http://
CENTRIFUGO_TOKEN_HMAC_SECRET_KEY=37246e8e-6943-444f-9f5c-c8d3241af361
CENTRIFUGO_ADMIN_PASSWORD=c32c421a-2123-4e8b-b063-c849e6dab599
CENTRIFUGO_ADMIN_SECRET=d37f2351-24e6-4373-9462-c2030e0eaf40
CENTRIFUGO_API_KEY=719521ac-72ce-4621-ad36-5fe0c8cbfd47

```

2. execute command `php artisan laravel:centrifugo:init` and clear cache.
3. Add to your `docker-compose` file this container

```
  centrifugo:
    container_name: centrifugo
    image: centrifugo/centrifugo:v3
    volumes:
      - ./docker/centrifugo/config.json:/centrifugo/config.json
    command: centrifugo -c config.json
    ports:
      - '8000:8000'
    ulimits:
      nofile:
        soft: 65535
        hard: 65535
    networks:
      -

```

### Usage

[](#usage)

#### Autogenerate config

[](#autogenerate-config)

Command `php artisan laravel:centrifugo:init` generate `config/centrifugo.php` for Laravel and `docker/centrifugo/config.json` for Centrifugo. It Generates for you default proxy routes by `.env` and centrifugo keys.

#### Security

[](#security)

By Default, it uses Laravel Passport Token for identify users and possible to connect Centrifugo. You can write your own Guard by implement `AuthGuardInterface`.

```
interface AuthGuardInterface
{
    public function auth(Request $request): int;

    public function encodeUserId(int $userId): string;

    public function decodeUserId(string $hashedUserId): int;
}

```

*auth(Request $request): int*

Give you Request with body that you can send, and you must return userID by whom WebSocket was connected.

*encodeUserId(int $userId): string*

Encoding User ID in unique string for security display User ID. By Default in use `Hashids` library.

*decodeUserId(string $hashedUserId): int*

Decoding Hashed User ID for correctly setUp User ID in events.

#### Proxy Events

[](#proxy-events)

Centrifugo has 4 proxy routes. We use only 3 of them because of refresh proxy unused by AuthGuard Authentication. You can select which of Users can connect to Centrifugo by Guarding You Application Token.

*connect*

After Successfully Guarded Your token it dispatches `ConnectEvent` with UserID.

*subscribe*

Dispatch `SubscribeEvent` with UsedID and Channel Name after User successfully subscribed on Channel

*publish*

Dispatch `PublishEvent` with UserID, Channel and Published Data after User successfully published data in Channel

#### FrontEnd usage

[](#frontend-usage)

You must use default [Centrifugo JS library](https://github.com/centrifugal/centrifuge-js). Example with default BearerToken Connection:

```
const centrifuge = new Centrifuge("ws://localhost:8000/connection/websocket");
centrifuge.setConnectData({
    token: bearerToken
});
centrifuge.connect();
let subscription  = centrifuge.subscribe(channel, function(ctx) {
    container.innerHTML = ctx.data.value;
    document.title = ctx.data.value;
});

```

By `centrifuge.setConnectData` you can send Any data to you Request Body in AuthGuard.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance50

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~333 days

Total

5

Last Release

362d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/505745a5e3bb1e2dfdeea4ad32f4dcf3cdb45b19bb4e1ca40ab58add2e4a42e3?d=identicon)[Zavrik94](/maintainers/Zavrik94)

---

Top Contributors

[![artem-zavrazhyn](https://avatars.githubusercontent.com/u/79974098?v=4)](https://github.com/artem-zavrazhyn "artem-zavrazhyn (25 commits)")[![zavrazhyn-artem](https://avatars.githubusercontent.com/u/34553294?v=4)](https://github.com/zavrazhyn-artem "zavrazhyn-artem (5 commits)")

### Embed Badge

![Health badge](/badges/zavrik-laravel-centrifugo/health.svg)

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

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.8k69.4k](/packages/grumpydictator-firefly-iii)[unopim/unopim

UnoPim Laravel PIM

10.3k2.2k](/packages/unopim-unopim)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

53675.5k16](/packages/solspace-craft-freeform)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)

PHPackages © 2026

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