Skip to content
Scalpels home

Sign up now for $10 in credit on a new Laravel Cloud account.

Idea

Can Campfire's Laravel port run on Laravel Cloud the Laravel way?

· Ed Grosvenor

37signals has released once-campfire-laravel, Campfire implemented natively in Laravel 13 and PHP 8.4. We have already put Campfire on Laravel Cloud twice. We did it once in Rails, on the early-access Ruby runtime, and once in Rust. This is the third and last one, and on paper it is the easy one. Laravel Cloud is Laravel's own platform. The hard parts of the first two experiments were all the places where a Rails or Rust application did not know what Cloud expects. A Laravel application should know.

Our fork is at artisan-build/campfire-laravel-experiment.

Before writing this we read the source. That is a direct lesson from the Rust run, where a summarising web fetch dropped one sentence from our own idea page and we spent half an experiment acting on the opposite of the truth. So we took a shallow clone and read the code itself, and reading it changed the experiment.

What we expected

We wrote down three guesses before we looked.

  1. It is SQLite, and moving to Postgres should be dead simple. Campfire has always been SQLite, and Cloud has no SQLite. But this is Eloquent now, and swapping a connection is a configuration change.
  2. Images and attachments are already solved. Laravel has a filesystem layer with an S3 driver built in. Anyone writing a Laravel app in 2026 uses it, so attaching a Cloud bucket should be most of the work.
  3. The websockets decide the experiment. Did the port convert Action Cable to Laravel's own broadcasting, which is Pusher-compatible and therefore already speaks to Cloud's managed Reverb, a hosted WebSocket server? If so, realtime becomes a config change, and realtime is what cost us the most in both previous runs.

All three are wrong, in the same direction and for the same reason. The port's goal is to be indistinguishable from the Rails app, including reading a Rails installation's database, uploads, and login cookies. Wherever Laravel's own way of doing something would have changed what is written to disk, the port went around Laravel instead.

What the code actually says

There are no migrations

database/ contains schema.sql and versions.json. That is it. The schema is Rails' SQLite schema, loaded as raw SQL, and there is a custom app/Support/SQLiteGrammar.php to make Laravel's query builder emit what that schema expects.

Search is an FTS5 virtual table. MessageWriter maintains it with raw INSERT/DELETE against message_search_index, and ChatController queries it with whereRaw('idx.body MATCH ?'). Queue, cache, and sessions all default to the database driver, in the same SQLite file, with a second SQLite file for jobs.

So the Postgres move takes more than a connection string. It means writing the schema as migrations, replacing a database-specific grammar, and rewriting search.

There is no Storage facade

The facade does not appear in the application at all. app/Support/BlobStorage.php writes Active Storage's on-disk layout with file_put_contents, under whatever path STORAGE_PATH names. Files are served through Rails-compatible signed URLs at /rails/active_storage/..., generated by a PBKDF2 implementation of Rails' message verifier in app/Support/RailsCrypto.php.

Variants are worse. app/Support/Media.php shells out to vips and ffmpeg as external programs, reading and writing local file paths under a flock. The VAPID keys for web push are read from storage/vapid.json.

Every one of those depends on the local disk, and on Cloud the local disk is gone after each deploy.

There is no broadcasting

There is no config/broadcasting.php. bin/cable is a Workerman websocket server that re-implements Action Cable's actioncable-v1-json protocol on 127.0.0.1, with its worker count pinned to one. The application does not broadcast to it over a network. app/Support/Broadcasts.php appends a JSON line to storage/events.log, under a lock, and the cable process tails that file.

A local file as the message bus is the most consequential fact in the repository. It means a message posted on instance A cannot reach a socket held by instance B, by construction. The port is a one-machine application, and it ships that way. It comes as a Docker image that runs nginx, eight PHP-FPM workers, a queue worker, and the cable process together. That is a shape Cloud does not have.

For completeness

PHP ^8.4, Laravel 13, PHPUnit rather than Pest, and four runtime dependencies: workerman/workerman, minishlink/web-push, ezyang/htmlpurifier, and bacon/bacon-qr-code. The README's own benchmarks put it behind Rails on most request paths. It serves 164 req/s against 242 on the room page, and 137 against 225 when posting a message. Median websocket delivery is 42 ms against Rails' 24 ms, measured on 100 connections.

Why there is an experiment here at all

If our three guesses had been right, there would be no experiment here. A Laravel app that already uses Eloquent migrations, Storage, and broadcasting mostly just deploys, and the write-up would be a paragraph.

Instead each pillar needs a real refactor, and every one of them has a first-party Laravel answer sitting there unused. The question is no longer "will it run on Cloud" but "what does this application look like when it is written the Laravel way", and Cloud is the thing that forces the answer.

The plan

Nothing has been deployed yet, so everything below is a prediction.

For the database, we write real migrations, move to Cloud's serverless Postgres, which can sleep when it is idle, and delete the custom grammar. We replace FTS5 with Postgres full-text search. Most likely that means whereFullText over a generated tsvector column with a GIN index, which is roughly what we ended up doing in the Rails run. Queue, cache, and sessions move onto managed drivers rather than database tables.

The blobs go in a Cloud bucket, which is S3-compatible object storage, through the Storage facade and the S3 driver, and BlobStorage's hand-rolled path layout goes away. The open question is the URLs. Campfire's frontend asks for /rails/active_storage/blobs/redirect/<signed id>/<filename>, and those signed ids are Rails message verifier output. Keeping the route and signing is cheap. Keeping them while the files live in a bucket needs a redirect to a temporary URL. Variants also need somewhere to generate from that is not a local disk.

For realtime, the Workerman server and the file outbox go, and the application broadcasts through Laravel's broadcasting to Cloud's managed Reverb. This is the part we are most confident about. Reverb is Pusher-compatible, and Cloud attaches it to a Laravel environment first-party. It would not do that for the Rails app, where we had to wire the connection by hand. The frontend has to move off Action Cable's consumer onto Echo and pusher-js. We already built a pusher-js shim for Campfire's own channel code in the Rails run, so we expect the browser half to be mostly a port rather than a design.

We expect to give up the Rails compatibility promises. The port promises to read an existing Rails installation's database, serve its blob paths, and accept its login cookies. Those promises are the reason the port is shaped the way it is, and they are the first thing that breaks when the schema becomes migrations and the blobs become a bucket. We think that is the right trade for this experiment.

Open questions

Will vips and ffmpeg be there? The port runs both as subprocesses, which is easier than the Rust port's situation (that one linked libvips into the binary), but it still needs the executables present on Cloud's PHP runtime. If they are not, variants either move to a library the runtime does have, or off the request path entirely.

Does compute actually hibernate? Cloud can put an application's compute to sleep when it gets no requests, which it calls hibernation. The Rust app never slept while a browser tab was open, because an upgraded websocket counts as an in-flight request for its whole life. If Reverb holds the sockets instead, the application's own compute should be free to sleep. That is a cost difference we want measured.

Where do the VAPID keys live? storage/vapid.json does not survive a deploy. Rotating them silently breaks every existing push subscription, so they need somewhere durable. Whatever we pick has to generate the keys itself rather than ask an installer to paste one.

And what does the first run do? The port's start script runs campfire:install before booting. On Cloud that has to become something that runs once, in the right place, and is safe to run again.

What success looks like

  1. Everything that can sleep, sleeps. Compute hibernation on, serverless Postgres, managed queues, and managed Reverb. If a resource can scale to zero and does not, that is a finding.
  2. Two instances behave like one application. A message posted on one reaches a socket held by the other. An upload accepted by one is served by the other. Sessions are shared. This is the bar the port currently cannot meet at all, and it is the clearest test of whether the refactor is real.
  3. The Laravel way, everywhere there is one. Migrations, Eloquent, Storage, broadcasting, queues, cache, config. It should work the way a Laravel developer would expect when they open the repository.

It also has to clear the same bar as the other two. Two people chat in real time, attachments live in a bucket, search works, and everything survives a redeploy.

What we expect to carry over

Read the dashboard deploy log first. Seventeen Rails deploys failed with the same unhelpful status before we found the real reason in the one place that showed it.

The IPv6 trap should be gone. Cloud's container network is IPv6-only, so a server has to listen on an IPv6 address. That cost us most of the Rails attempt. Cloud runs the PHP runtime itself, so binding is not ours to get wrong. We should also avoid the websocket upgrade problem by going around it. Cloud's per-instance proxy does not forward the Upgrade and Connection headers. That is why we bolted a Pusher adapter onto Reverb in the Rails run, and rewrote the raw request in front of the app's own parser in the Rust run. Using Reverb from the start means we never ask the app to hold a socket. What does carry over from that fight is the browser half. That means the pusher-js shim and the channel authorisation endpoint that reuses Campfire's own room permissions.

The S3 checksum clash may return. Cloud's object storage rejected an upload carrying both a CRC32 and an MD5 from the Ruby SDK, so check what Flysystem's S3 adapter sends before assuming it is fine. The secrets also have to stay stable. SECRET_KEY_BASE and the VAPID keys behave the same way here. Rotate either and you sign everyone out or break push.

Why we are not keeping the diff small

In the first two experiments we optimised for a minimal diff, because the question was "how much does upstream have to change". That question does not apply here. This port is itself an agent-led experiment, pinned against a Rails reference, and we do not expect 37signals to maintain it. Ours would be a continuation of it rather than a patch on top.

So the plan is to change whatever needs changing. If it works, the result is a Campfire written for Laravel and at home on Cloud, and that is something Artisan Build could maintain for the Laravel community.

This is the last of the three. When it is done we decide whether any of the three (Rails, Rust, or this one) becomes a maintained "Campfire optimised for Cloud", or whether we have learned what we came for and move on.

Experiments on this idea

  1. Experiment

    We ran Campfire's Laravel port on Laravel Cloud the Laravel way

    We guessed that none of this would be a configuration change, and we were right. We did not guess three things. A rendered Campfire message is too big for a frame on Reverb, Laravel's WebSocket server. The signal we first used to show that compute sleeps was really measuring deployments. And Reverb, the one resource that cannot sleep, is also the one that makes this the Laravel way.

    Read the experiment

Support the Lab

The Lab runs on our supporters

Every idea here gets tried for real: deployed, broken, fixed and written up. Right now that is one person doing the work between everything else, and supporters are what buy the time. As support grows, it will also pay freelancers to run experiments of their own, so more of these ideas get tested, sooner.

Our supporters

  • Chill Vibes

    A curated collection of fun and interesting experiments and projects built with AI to entertain and educate.

    Supporter Visit
    Visit Chill Vibes
  • Fawnfox Fables

    Create and publish your own children's books. Stories built around the people you love.

    Supporter Visit
    Visit Fawnfox Fables
  • Sputnik Intelligence

    Spain

    We transcribe the podcasts and read the newsletters, and make them searchable. Set up alerts, or hand it all to your AI agent over MCP or API.

    Supporter Visit
    Visit Sputnik Intelligence
  • Team of Me

    Free resources for indie makers and people thinking about striking out on their own.

    Supporter Visit
    Visit Team of Me
  • Wicked Viral

    Earth

    Connecting builders with promoters who can help them take their products to market. Get your product listed today!

    Supporter Visit
    Visit Wicked Viral