Deploying Laravel Rust to Laravel Cloud
Ship a Laravel Rust app to Laravel Cloud: build and deploy commands, environment variables, queues, the scheduler and file storage, with notes for anyone who has deployed Laravel PHP.
- deploy
- laravel-cloud
- production
On this page
Deploying Laravel PHP to Laravel Cloud means pushing your code and letting Cloud run Composer, your asset build and your migrations. Laravel Rust works the same way, except that your app is compiled into a single binary before it runs, and most of this guide follows from that.
The app being deployed is departures, an airport departures board: flights, gates and live status changes, with a queued job that texts passengers when their gate moves. Swap in your own project name wherever you see departures.
What Cloud runs
cargo build --release produces one executable, named after your project: target/release/departures. Your migrations are compiled into it, so the server never needs your source code to run migrate.
The binary still reads a few folders at runtime: public/ (where npm run build puts your assets), resources/views/, and storage/. Cloud builds from your repository, so these folders come along with it.
Laravel Rust knows when it’s running on Cloud. It listens on the address and port Cloud gives it, so you don’t set SERVER_HOST or SERVER_PORT, and every environment gets its own APP_KEY.
The two command boxes
When you create the Cloud environment, fill in the build commands and the deploy commands:
# Build commands
cargo build --release
npm ci && npm run build
# Deploy commands
departures migrate --force
Build commands compile the binary and the frontend. Deploy commands run against the new build before it takes traffic. migrate asks for confirmation in production, so --force is required in a script. Cloud runs deploy commands once per deploy, however many instances you have, so you don’t need to arrange a single migration server yourself.
Tip: the build is the slow part. Rust checks a lot at compile time. Laravel’s launch post gives a median cold build on Cloud of about three minutes, against 27 seconds for Laravel PHP.
If you use Inertia server-side rendering, build with npm run build:ssr instead and set INERTIA_SSR=true in the environment.
Environment variables
Coming from Laravel PHP, the list is short and familiar. At a minimum, production needs:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://departures.example.com
DATABASE_URL=postgres://user:secret@db-host/departures
APP_KEY is the one you don’t set on Cloud: each environment gets its own. Use a different key from the one on your machine wherever you deploy.
Tip:
APP_DEBUG=false, always. With debug on, a server error renders a page showing the error, its causes, the route and the request, to anyone who triggers it.
Queues: one feature flag and one variable
The gate-change texts go out from a queued job. On Cloud, you don’t run a worker yourself. Enable the sqs feature on the laravel-rust dependency in Cargo.toml (the starter app already includes it), then set:
QUEUE_CONNECTION=cloud
Your jobs now go to Cloud’s managed queues, whose workers scale with the number of jobs waiting. Laravel’s launch post notes that only Laravel Rust, of the Rust frameworks Cloud runs, works with these managed queues.
If you ever run your own workers elsewhere, remember that a worker runs the code it was compiled with: restart workers on every deploy, or they keep running the old binary.
The scheduler
Say the board archives yesterday’s flights every night. On your own server you’d add the familiar cron line that calls schedule:run every minute. On Cloud there’s nothing to add: its built-in scheduler runs your scheduled tasks, and it wakes the app on time even if the app has scaled to zero.
Files
Anything the app writes to a local storage/ folder belongs to a single instance, and most hosts erase it on every deploy. Keep uploads, such as the airline logos on the board, in Laravel Cloud Object Storage or another S3-compatible disk instead.
Real-time updates
A departures board wants to push “Boarding” to every screen the moment it changes. Laravel Rust includes a Reverb WebSocket server you can run locally with laravel reverb:start, but in production on Cloud, switch your environment variables to Cloud’s managed Reverb instead of running that server yourself.
What Cloud handles for you
Cloud also takes care of autoscaling with scale to zero, preview environments for every pull request, managed Postgres, MySQL and Valkey, HTTPS, logs and metrics. The same app also deploys anywhere else you can run a binary; the deployment docs cover systemd, load balancers and health checks for that route.
Checklist
| You did this for Laravel PHP | Do this for Laravel Rust |
|---|---|
composer install in the build |
cargo build --release in the build |
npm ci && npm run build |
The same |
php artisan migrate --force on deploy |
departures migrate --force on deploy |
And for Laravel Rust on Cloud specifically:
APP_ENV=production,APP_DEBUG=false,APP_URLandDATABASE_URLset.- The
sqsfeature enabled andQUEUE_CONNECTION=cloudif you queue jobs. - Uploads on Object Storage or S3, never local
storage/. - Managed Reverb, not
reverb:start, for broadcasting. npm run build:ssrandINERTIA_SSR=trueif you use server-side rendering.