Skip to content
cabby

Laravel

Cabby speaks the same protocol as AnyCable, so it works with Laravel broadcasting through the anycable/laravel-broadcaster package, which works with either server. Your events and routes/channels.php stay the same. Requires PHP 8.2+ and Laravel 11+.

1. Install the broadcaster

New app? Turn on broadcasting first. This adds config/broadcasting.php and routes/channels.php:

php artisan install:broadcasting --without-reverb --without-node

If it asks for a driver, pick Laravel Reverb. Reverb itself isn't installed, and step 2 switches the driver.

Then add the package:

composer require anycable/laravel-broadcaster -W

-W lets Composer use Guzzle 7, which the package needs.

Register the provider in bootstrap/providers.php:

return [
    App\Providers\AppServiceProvider::class,
    AnyCable\Laravel\Providers\AnyCableBroadcastServiceProvider::class,
];

Add the connection to config/broadcasting.php:

'connections' => [
    'anycable' => [
        'driver' => 'anycable',
    ],
    // ...
],

2. Configure it

BROADCAST_CONNECTION=anycable
ANYCABLE_SECRET=change-me
ANYCABLE_HTTP_BROADCAST_URL=http://localhost:8080/_broadcast

3. Connect Echo

npm install laravel-echo @anycable/echo

Replace the contents of resources/js/echo.js. install:broadcasting created that file and imports it from resources/js/bootstrap.js.

// resources/js/echo.js
import Echo from "laravel-echo"
import { EchoCable } from "@anycable/echo"

window.Echo = new Echo({
  broadcaster: EchoCable,
  cableOptions: { url: "ws://localhost:8080/cable" },
})

4. Run Cabby

Install Cabby if you haven't yet, then run cabby instead of the package's php artisan anycable:server:

cabby --norpc --noauth --secret=change-me --presets=broker

--noauth lets visitors connect without Cabby calling your app; private and presence channels still need a signed name from /broadcasting/auth. --presets=broker turns on the in-memory broker that presence channels need. If you use public channels (Echo.channel), add --public_streams. It lets any client subscribe to any channel by name, including private- and presence- ones, so don't combine it with channels that must stay private.

Broadcast as usual:

OrderShipped::dispatch($order);

Private and presence channels are authorized through Laravel's usual /broadcasting/auth endpoint and your Broadcast::channel callbacks.

Alternative: Pusher protocol

If you already use Laravel Reverb or Pusher, Cabby also speaks the Pusher protocol. Keep the pusher-js client and your Reverb settings, and start Cabby with the same credentials:

cabby --norpc --secret=change-me --presets=broker --pusher_app_id=app-id --pusher_app_key=app-key --pusher_secret=app-secret

As above, presence channels need --presets=broker. --secret puts Cabby's own /_broadcast endpoint on the main port and requires a key for it; Pusher clients and the Pusher HTTP API use the --pusher_* credentials.