Skip to content

Run a Laravel app's Reverb server for its site #50

Description

@sineld

What's missing

Laravel apps that broadcast with Reverb need php artisan reverb:start running, plus a WebSocket endpoint the browser can reach. With Flock, users start it by hand on a port of its own. Then they need a second origin or extra TLS setup, because the site is https://app.test and Echo has to connect over wss://.

Approach

Make it a per-site setting, like FrankenPHP:

flock reverb on [site]       # also off, restart, and `flock reverb` for its state
  • The process: the daemon supervises php artisan reverb:start --host=127.0.0.1 --port=<port> --hostname=127.0.0.1 with the site's PHP version. The port comes from the 21000+ range FrankenPHP already uses.

  • The web server: it sends the site's own Pusher-protocol requests to that port:

    • WebSocket connections on /app/*, for wss://app.test/app/<key>
    • signed broadcasts on /apps/*

    Anything else on those paths stays the app's, so a panel at /app keeps working. No extra port, origin or certificate is needed.

  • Setup help: flock reverb shows the three .env lines the app needs (REVERB_HOST, REVERB_PORT, REVERB_SCHEME).

  • API and MCP: the API (PATCH /v1/sites/{name} with "reverb") and the MCP update_site tool can turn it on and off.

Status

The implementation is ready as #21 for the CLI, daemon, API and MCP. It was tested end to end with Laravel 13 and Reverb behind Flock's Caddy. The macOS, Windows and Linux (#19) apps could add a toggle next to FrankenPHP in a follow-up.

I opened it before the issue rule existed and will add Fixes #<this> once this is approved, along with a section in docs/sites.md.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions