PHPackages                             gos/pubsub-router-bundle - 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. [Caching](/categories/caching)
4. /
5. gos/pubsub-router-bundle

ActiveSymfony-bundle[Caching](/categories/caching)

gos/pubsub-router-bundle
========================

Symfony PubSub Router Bundle

v2.8.0(3y ago)442.2M—7.2%71MITPHPPHP ^7.2 || ^8.0

Since Apr 11Pushed 3y ago5 watchersCompare

[ Source](https://github.com/GeniusesOfSymfony/PubSubRouterBundle)[ Packagist](https://packagist.org/packages/gos/pubsub-router-bundle)[ Docs](https://github.com/GeniusesOfSymfony/PubSubRouterBundle)[ GitHub Sponsors](https://github.com/mbabker)[ RSS](/packages/gos-pubsub-router-bundle/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (44)Used By (1)

GosPubSubRouterBundle
=====================

[](#gospubsubrouterbundle)

[![Latest Stable Version](https://camo.githubusercontent.com/d76fe1d469d3a644dd7c627cbf4ec2513f45ad9f0ec336a22a8c067e8aedd6df/68747470733a2f2f706f7365722e707567782e6f72672f676f732f7075627375622d726f757465722d62756e646c652f762f737461626c65)](https://packagist.org/packages/gos/pubsub-router-bundle) [![Latest Unstable Version](https://camo.githubusercontent.com/59601b8ee64b4325057b2f43dd4e1d6913693a2be1a7e45d3f017416e31b96ce/68747470733a2f2f706f7365722e707567782e6f72672f676f732f7075627375622d726f757465722d62756e646c652f762f756e737461626c65)](https://packagist.org/packages/gos/pubsub-router-bundle) [![Total Downloads](https://camo.githubusercontent.com/ba606c654d47cd57830f812355811bf153fafa38359ff3dfc70d655406ca6cdb/68747470733a2f2f706f7365722e707567782e6f72672f676f732f7075627375622d726f757465722d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/gos/pubsub-router-bundle) [![License](https://camo.githubusercontent.com/0a5af8569faac04b099463f8586ef3cb3f81a315c4bf66a52e070c4303d7ec14/68747470733a2f2f706f7365722e707567782e6f72672f676f732f7075627375622d726f757465722d62756e646c652f6c6963656e7365)](https://packagist.org/packages/gos/pubsub-router-bundle) [![Run Tests](https://github.com/GeniusesOfSymfony/PubSubRouterBundle/workflows/Run%20Tests/badge.svg?branch=2.x)](https://github.com/GeniusesOfSymfony/PubSubRouterBundle/workflows/Run%20Tests/badge.svg?branch=2.x)

About
-----

[](#about)

GosPubSubRouterBundle is a Symfony Bundle whose goal is to plug any logic behind pubsub channel. When you use PubSub pattern you will make face to a problem, rely channels with business logic. PubSub router is here to make the junction between channel and business logic.

Support
-------

[](#support)

VersionStatusSymfony Versions1.x**No Longer Supported**3.4, 4.4, 5.2-5.42.xActively Supported4.4, 5.3-5.4, 6.03.xIn Development5.3-5.4, 6.0Features
--------

[](#features)

- Route definition
- Route matching
- Route generator

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

[](#installation)

Add the bundle to your project using [Composer](https://getcomposer.org/):

```
composer require gos/pubsub-router-bundle
```

Once installed, you will need to add the bundle to your project.

If your project is based on Symfony Flex, the bundle should be automatically added to your `config/bundles.php` file:

```
Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle::class => ['all' => true],
```

If your project is based on the Symfony Standard Edition, you will need to add the bundle to your Kernel's `registerBundles` method by editing `app/AppKernel.php`:

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new \Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle()
        );

        ...
    }
```

Bundle configuration

Below is an example bundle configuration. For projects based on Symfony Flex, this should be stored in `config/packages/gos_pubsub_router.yaml`. For projects based on Symfony Standard Edition, this should be added to `app/config/config.yml`.

```
#Gos PubSub Router
gos_pubsub_router:
    routers:
        websocket: #available from container through gos_pubsub_router.websocket
            resources:
                - @GosNotificationBundle/Resources/config/pubsub/websocket/notification.yml
        redis: #available from container through gos_pubsub_router.redis
            resources:
                - @GosNotificationBundle/Resources/config/pubsub/redis/notification.yml
```

**NOTE** : Each router is insulated. If you have several routers in the same class you will need to inject each router that you need.

Usage
-----

[](#usage)

### Routing definition

[](#routing-definition)

Example with websocket pubsub

```
user_notification:
    channel: notification/user/{role}/{application}/{user_ref}
    handler: ['Acme\Chat\MessageHandler', 'addPushers']
    requirements:
        role: "editor|admin|client"
        application: "[a-z]+"
        user_ref: "\d+"
```

Example with redis pubsub

```
user_app_notification:
    channel: notification:user:{role}:{application}:{user_ref}
    handler: ['Acme\Chat\MessageHandler', 'addPushers']
    requirements:
        role: "editor|admin|client"
        application: "[a-z-]+-app"
        user_ref: "\d+"
```

**NOTE** : The handler is not typehinted, this allows you to define the handler callback in any way you'd like (such as an array to call a method on a class or a string to call a PHP function or a service from the container).

### Use router

[](#use-router)

Let's generate a route !

```
$router = $this->container->get('gos_pubsub_router.websocket');
$channel = $router->generate('user_notification', ['role' => 'admin', 'application' => 'blog-app', 'user_ref' => '123']);

echo $channel // notification/user/admin/blog/123
```

Match your first route !

```
use Gos\Bundle\PubSubRouterBundle\Request\PubSubRequest;

$channel = 'notification/user/admin/billing-app/639409'; // 'notification/user/admin/billing-app/*' work :)

list($routeName, $route, $attributes) = $router->match($channel);

$request = new PubSubRequest($routeName, $route, $attributes); //Create a request object if you want transport the request data as dependency

//$request->getAttributes()->get('user_ref'); it's a parameterBag

// $router->match($channel);

// $routeName -> 'user_app_notification
// $route -> instance of Gos\Bundle\PubSubRouterBundle\Router\Route
// $attributes -> [ 'role' => 'admin', 'application' => 'billing-app', 'user_ref' => '639409' ]
```

What about mismatch?

```
use Gos\Bundle\PubSubRouterBundle\Exception\ResourceNotFoundException;

$channel = 'notification/user/admin/billing-app/azerty'; // will miss match

try {
    list($routeName, $route, $attributes) = $router->match($channel);
} catch (ResourceNotFoundException $e) {
    //handle exception
}
```

- If you only need to generate route, typehint against `Gos\Bundle\PubSubRouterBundle\Generator\GeneratorInterface`
- If you only need to match route, typehint against `Gos\Bundle\PubSubRouterBundle\Matcher\MatcherInterface`
- If you need both, typehint against `Gos\Bundle\PubSubRouterBundle\Router\RouterInterface`

### Router CLI

[](#router-cli)

`php bin/console gos:prouter:debug -r websocket` dump all registered routes for websocket router

License
-------

[](#license)

MIT, See `LICENSE` file in the root of project.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 93% 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 ~63 days

Recently: every ~79 days

Total

44

Last Release

1337d ago

Major Versions

v1.5.0 → v2.1.02020-02-20

v1.6.0 → v2.3.02020-11-02

v1.7.0 → v2.6.02021-06-17

1.x-dev → v2.7.02021-11-07

2.x-dev → 3.x-dev2022-09-20

PHP version history (6 changes)v0.1.0PHP &gt;=5.5

v0.1.8PHP &gt;=5.4

v1.0.0PHP &gt;=7.1

v1.2.0PHP ^7.2

v1.6.0PHP ^7.2 || ^8.0

3.x-devPHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2697e85bca7c41cb6166cf78dca3156bdbbe7950189f0b958115201dcd9a919a?d=identicon)[ProPheT777](/maintainers/ProPheT777)

---

Top Contributors

[![mbabker](https://avatars.githubusercontent.com/u/368545?v=4)](https://github.com/mbabker "mbabker (294 commits)")[![Prophet777](https://avatars.githubusercontent.com/u/76678181?v=4)](https://github.com/Prophet777 "Prophet777 (12 commits)")[![Kolbasyatin](https://avatars.githubusercontent.com/u/7057456?v=4)](https://github.com/Kolbasyatin "Kolbasyatin (3 commits)")[![fortis](https://avatars.githubusercontent.com/u/1042494?v=4)](https://github.com/fortis "fortis (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")[![aleksa2808](https://avatars.githubusercontent.com/u/7463511?v=4)](https://github.com/aleksa2808 "aleksa2808 (1 commits)")[![Kronhyx](https://avatars.githubusercontent.com/u/16559276?v=4)](https://github.com/Kronhyx "Kronhyx (1 commits)")[![matthieuy](https://avatars.githubusercontent.com/u/5350047?v=4)](https://github.com/matthieuy "matthieuy (1 commits)")[![DeRain](https://avatars.githubusercontent.com/u/3999180?v=4)](https://github.com/DeRain "DeRain (1 commits)")[![darthf1](https://avatars.githubusercontent.com/u/17253332?v=4)](https://github.com/darthf1 "darthf1 (1 commits)")

---

Tags

phppubsub-routersymfony-bundlebundleredisWAMPpubsubzmqPubSub Bundle

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gos-pubsub-router-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/gos-pubsub-router-bundle/health.svg)](https://phpackages.com/packages/gos-pubsub-router-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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