Laravel Octane boots your app once and keeps it in memory, so each request skips the framework bootstrap. With FrankenPHP as the server, a typical app answers several times faster on the same hardware. Cipi runs it natively, without containers, next to your PHP-FPM apps.
$ cipi app create shop --octane $ cipi app convert legacy --to=octane $ cipi frankenphp upgrade --all
Key ideas, in plain words#
| Term | Meaning |
|---|---|
| PHP-FPM | The classic way: PHP boots Laravel for every request |
| Octane | Boots Laravel once and keeps it in memory; requests reuse it |
| FrankenPHP | A modern PHP server (one binary with PHP inside) that Octane runs on |
| Octane worker | One long-lived process handling requests in turn |
| State leak | Data from one request still in memory during the next: the main thing to avoid |
Classic PHP: for every request, Laravel boots (config, providers, routes), handles the request, then everything is thrown away.
Octane: Laravel boots once per worker and stays in memory; each request skips the boot. Faster, but data you leave in memory carries over to the next request.
Before you start#
- A Laravel app on Cipi (first deploy) with a test suite.
- About 150 MB of free RAM per Octane worker you plan to run.
1. Prepare the project#
composer require laravel/octane php artisan octane:install --server=frankenphp
Commit both changes. Octane apps keep state between requests: avoid storing per-request data in static properties or singletons. The Octane docs list the patterns to watch.
2. Create the app as Octane, or convert one#
sudo cipi app create --user=shop --domain=shop.example.com \
--repository=git@github.com:acme/shop.git --octane
sudo cipi deploy shopAn existing app moves over (and back) in one command; the certificate is kept:
sudo cipi app convert shop --to=octane sudo cipi app convert shop --to=fpm
3. What runs on the server#
Nginx handles HTTPS and serves static files from public/ itself.
Other requests go to Octane on a local port (8100–8999), unreachable from outside.
The app runs on its own pinned FrankenPHP build, so PHP never changes by surprise.
Supervisor keeps Octane alive and reloads it on every deploy.
| Piece | Setting |
|---|---|
| Nginx | Serves current/public directly and proxies the rest to the app's local port |
| Process | Supervisor program shop-octane, next to the queue workers |
.env | OCTANE_SERVER=frankenphp, OCTANE_HTTPS=true |
| Deploys | The pinned binary is linked into the new release, then Octane reloads |
4. Tune the workers#
sudo cipi app limits shop --octane-workers=4
Start with one worker per CPU core and watch memory with sudo cipi status. Long jobs belong on queues or Horizon, WebSockets on Reverb.
5. Keep FrankenPHP patched, safely#
sudo cipi frankenphp # each app's build and PHP, patched or not sudo cipi frankenphp upgrade shop # newest build on the same PHP minor
| Guard | Effect |
|---|---|
| Upgrades stay on the app's PHP minor | No surprise PHP jump |
| Octane must answer after an upgrade | Otherwise the previous build comes back |
Nightly patches via cipi autoupdate | Security fixes without manual work |
To move to a new PHP minor: sudo cipi app edit shop --php=8.6, then sudo cipi frankenphp upgrade shop.
In cipi.yml#
The runtime is chosen at creation or with convert; worker counts can live in the repository:
app:
limits: { octane_workers: 4 }Avoid state leaks#
| Risky | Safer |
|---|---|
static $cache = [] in a service | Laravel's cache, or reset it per request |
Injecting Request into a singleton's constructor | Resolve the request inside the method |
| Singletons holding the logged-in user | Bind as scoped() instead of singleton() |
| Growing arrays in long-lived objects | Octane recycles each worker after 500 requests by default, which limits the damage, not the cause |
Troubleshooting#
| Problem | Fix |
|---|---|
| 502 Bad Gateway | Octane isn't running: sudo cipi worker list shop, then sudo cipi app logs shop --type=worker |
| One user sees another's data | A state leak: see the table above |
.env change ignored | cipi app artisan shop config:cache, then cipi worker restart shop |
| Memory climbs until restart | A leak in a long-lived object: find it (static arrays, listeners added per request); lower the worker count meanwhile |
cipi php upgrade lists the app | Its FrankenPHP build is behind: sudo cipi frankenphp upgrade shop |
| Uploads larger than a few MB fail | Raise client_max_body_size and upload_max_filesize with cipi ini |
Questions
Do I need Docker for FrankenPHP?
No. Cipi runs the FrankenPHP binary natively under Supervisor, behind Nginx, like any other process.
Can Octane and PHP-FPM apps share a server?
Yes. Each app picks its runtime; you can convert one back and forth with cipi app convert.
Will a deploy change my PHP version?
No. Each Octane app is pinned to a FrankenPHP build. PHP changes only when you run cipi frankenphp upgrade or switch the app's PHP version.
Is Octane always faster?
For most apps, yes: requests skip the framework boot. Apps dominated by slow database queries or external APIs gain less; fix those first.
What breaks under Octane?
Code that keeps per-request data in static properties, singletons resolved once with the request inside, or global state. Test with php artisan octane:start --watch locally.
How much memory does it use?
Each Octane worker keeps the app in memory, often 60–150 MB. Workers × memory must fit alongside your database and queues.
How do I reload Octane after changing .env?
Rebuild the config cache and restart: cipi app artisan shop config:cache, then cipi worker restart shop. A deploy does both.