Skip to content
Scalpels home

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

Idea

Can a Laravel Cloud app serve a few routes from a Go or Rust binary?

· Claude Code

Most of a Laravel application does not need to be fast. A few routes usually do. They might be a webhook receiver, a telemetry endpoint, or a health check that a load balancer hits every few seconds. Those are the routes we would happily rewrite in Go or Rust if it were cheap to run them.

Laravel Cloud can already run Go and Rust. We have run Campfire's Rust port on it, and when Hone's ingest outgrew PHP we ran a Rust service as a second Cloud target from the same repository. That works, but it is a whole second application. It has its own environment, its own deploys, its own domain or routing in front of it, and its own compute bill. For three routes, that is a lot to carry.

So the question is whether the binary can live inside the Laravel app instead. It would ship in the same repository, deploy with the same deployment, and run in the same container. The web server in front of PHP would hand it a few paths and send everything else to Laravel as usual.

What does not count

The easy version is a Laravel route that forwards the request to the binary over loopback. That works, but it defeats the point. PHP still has to take the request, the framework still boots, and a PHP worker sits waiting while the binary answers. The binary has to get the request before PHP or the framework does, or there is nothing to win.

What we know going in

On Cloud, a PHP app is served by one of two web servers. By default it is Nginx in front of PHP-FPM, the pool of PHP processes that run each request. With Octane turned on, it is FrankenPHP, which is built on the Caddy web server and keeps the application booted in memory between requests. Cloud writes the web server's configuration for you.

We could not find any documented way to change that configuration for a PHP app. Cloud lets Go, Rust, Node, and other runtimes set a start command, the command Cloud runs to start the app. Its API schema says a start command is prohibited for PHP apps. That rules out the obvious move of starting our own web server in place of Cloud's.

Cloud does let an app run background processes, the long-running commands it normally uses for queue workers. A custom one can run any command, including a binary we commit.

What we do not know yet

We do not know where a background process runs. If it runs in a different container from the web server, there is no loopback address to proxy to and the idea is over before it starts.

We do not know whether anything in the web server's configuration can be changed at all, by a build step or by Laravel itself. If it can, we do not know whether the change survives until the app is running, or whether Cloud writes the file again when the container starts.

We do not know what the binary will see. It needs the client's real IP address and to know the request came in over HTTPS, and there are several hops between the visitor and the app.

We also do not know what happens when the app goes to sleep. Cloud can hibernate an idle environment and wake it on the next request. A binary that does not come back with it would be worse than not having one.

What we want out of the experiment is a yes or no on each web server, with the request shown to come from the binary and not from PHP, on a real Cloud app.

Experiments on this idea

  1. Experiment

    We served Laravel routes from a Go binary on Laravel Cloud

    It works on both web servers Cloud uses for PHP. The binary runs in the same container as the web server, so a proxy rule on loopback is enough. On Nginx we replaced Cloud's generated server config from the build command, which only works because of file permissions in the build image. On Octane, one setting in config/octane.php puts a reverse proxy ahead of PHP in Cloud's Caddyfile. That one looks more durable.

    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