PHPackages                             calen/router - 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. calen/router

ActiveLibrary

calen/router
============

Laravel Ratchet Router

1.0.0(9y ago)112MITPHPPHP ^7.0

Since Aug 7Pushed 9y ago2 watchersCompare

[ Source](https://github.com/MrCalen/LaravelWSRouter)[ Packagist](https://packagist.org/packages/calen/router)[ RSS](/packages/calen-router/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Laravel WS Router
=================

[](#laravel-ws-router)

The Router provides a good way to do kind or URL routing for websockets. The library depends on cboden/ratchet which is the WebSocket server used but feel free to write the same for other WebSocket servers.

The library works based on the fields `path` given in the JSON message. All the configuration is done via the router.php file published.

The library handles Middlewares, Prefixes namespaces in grouping similarly to Laravel 5 URL routing.

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

[](#installation)

Require Calen/router in your L5 project. I used PHP7 to write it, so it has a dependency on it.

` composer require calen/router`

Then add the Service Provider in the providers in L5 *config/app.php*:

```
 'providers' => [
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

    // ...

    Calen\Router\RatchetRouterServiceProvider::class,

 ],

```

Once the ServiceProvider is added, you can publish the configuration file by running artisan:

`php artisan vendor:publish`

This will add the config file *router.php* in the config repository.

Configuration
-------------

[](#configuration)

You will need to configure the library for it to run correctly. The config file publishes as this:

```
return [
    'middlewares' => [
        // 'test' => App\WS\AuthMiddleware::class,
    ],
    'routes' => function ($routes) {
        $routes->group(['namespace' => 'App\Http\Controllers'], function ($routes) {
            $routes->route('/', 'HomeController@index');
        });
    },
];

```

### Middlewares

[](#middlewares)

The middlewares look the same as the L5's ones. If you want to provide a middleware on some routes on can add the `middleware` key to the array given in `group` function.

The middleware must implement the Calen\\Router\\Routing\\Middleware\\Middleware interface.

For example:

```
$routes->group(
    [
        'namespace' => 'App\Http\Controllers',
        'middleware' => 'dummy',
        'prefix' => 'CalenApp',
    ], function ($routes) {
        // My routes
    });

```

We add the middleware *dummy* to all the routes given in the closure.

As L5, the middleware are registered in the *config/router.php* file, as a name to the class corresponding like this:

```
return [
    'middlewares' => [
        'dummy' => App\WS\Dummyddleware::class,
    ],
    'routes' => function ($routes) {
        $routes->group(['namespace' => 'App\Http\Controllers'], function ($routes) {
            $routes->route('/', 'HomeController@index');
        });
    },
];

```

\####Note: *If the middleware is not registered, it will not be handled*

### Packagist

[](#packagist)

My packagist repo is here:

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3562d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dd10e641b4f73aca1b3dfdb957c8c186dd942460a1d3685c4e9c95cc18a93b5c?d=identicon)[Calen](/maintainers/Calen)

### Embed Badge

![Health badge](/badges/calen-router/health.svg)

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

###  Alternatives

[gos/web-socket-bundle

Symfony Web Socket Bundle

6202.2M8](/packages/gos-web-socket-bundle)[consik/yii2-websocket

Yii2 websocket server component

9275.9k2](/packages/consik-yii2-websocket)[takielias/codeigniter-websocket

CodeIgniter Websocket using Ratchet Websocket technology. Inspired by https://github.com/romainrg/ratchet\_client

609.1k](/packages/takielias-codeigniter-websocket)[joni-jones/yii2-wschat

Online chat based on web sockets and ratchet php

981.3k](/packages/joni-jones-yii2-wschat)[puko/framework

MVC Framework for quick and fast PHP application development.

1315.1k2](/packages/puko-framework)[lion/bundle

Lion-framework configuration and initialization package

122.2k1](/packages/lion-bundle)

PHPackages © 2026

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