Build your application
Detection
Cloud detects a Laravel Rust application from thelaravel-rust dependency in the Cargo.toml file at the root of your repository. Cloud builds with a recent stable Rust release, or with the toolchain pinned in your rust-toolchain.toml file. Laravel Rust requires Rust 1.99 or later.
Build commands
Cloud pre-fills your environment’s build commands to compile your frontend assets, then your application:/var/www/bin and adds that directory to your PATH. Your application’s binary is named after the name in your Cargo.toml file, so an application created with laravel new example-app builds an example-app binary.
Cloud caches your downloaded crates and compiled dependencies between builds of the same environment, so later builds can recompile only what changed. Commit your Cargo.lock file to make the most of the cache. Build commands must complete within 15 minutes.
Cargo features
Laravel Rust compiles drivers for databases, caches, and queues only when you enable the matching Cargo feature. Before a deployment builds, Cloud checks that yourlaravel-rust dependency enables a feature for each resource attached to your environment:
If a feature is missing, the deployment fails and names the features to add. New applications enable
database-postgres, redis, and sqs. To attach a MySQL database, change database-postgres to database-mysql:
Run your application
Cloud sets your environment’s start command to run your application’s binary, such as/var/www/bin/example-app. Running the binary without arguments serves your application.
On Cloud, Laravel Rust listens on the IPv6 wildcard address and the port Cloud provides through the PORT environment variable, so there is nothing to configure. When Cloud stops an instance, the server stops accepting new connections and waits up to 20 seconds for running requests to finish. To change that wait, set the SERVER_SHUTDOWN_TIMEOUT environment variable.
Application key
Cloud generates anAPP_KEY for each environment when you create it, and sets APP_ENV=production, APP_DEBUG=false, and APP_URL on every deployment. Keep each environment’s key secret, and don’t copy your local .env file’s key to Cloud.
Health checks
New Laravel Rust applications serve a health route at/up, registered with .health("/up") in src/app.rs. The route responds once your application has started. Point your environment’s startup and readiness health checks at /up so a deployment goes live only once your application can serve requests.
Run commands
Laravel Rust compiles its console commands into your application’s binary, so there is noartisan file. Run a command by passing it to your binary. Because /var/www/bin is on your PATH, you may use the binary’s name:
Run migrations
New environments include a commented-out deploy command that runs your migrations:--force option skips the confirmation that Laravel Rust asks for in production.
Databases and caches
When you attach a database, Cloud sets theDATABASE_URL environment variable, and Laravel Rust chooses its driver from the URL. Make sure your laravel-rust dependency enables the matching Cargo feature.
When you attach a cache, such as Laravel Valkey, Cloud sets REDIS_URL and CACHE_STORE=redis. Without a cache, Laravel Rust stores cached values in each instance’s memory, so instances don’t share them. If your application runs on more than one instance, attach a cache or set CACHE_STORE to another shared store, such as database.
Queues
Laravel Rust supports managed queues. When you attach a managed queue, Cloud setsQUEUE_CONNECTION=cloud and the queue’s configuration for you. Managed queues require the sqs Cargo feature. Failed jobs appear in the Cloud dashboard, where you may retry them.
To process jobs on your own compute instead, add a queue worker to your App cluster or a worker cluster. Cloud runs your binary’s queue:work command, such as example-app queue:work. Without a managed queue, Laravel Rust uses its database queue connection by default.
Task scheduling
To run your application’s scheduled tasks, click your environment’s App cluster or a worker cluster on the infrastructure canvas and enable the Scheduler toggle. Then, save and redeploy. Cloud runs your binary’sschedule:work command, which runs your due tasks every minute. When your environment scales to zero, Cloud wakes it to run scheduled tasks.
Other resources
- Object storage: When you attach a bucket, Cloud sets
LARAVEL_CLOUD_DISK_CONFIG, and Laravel Rust adds a disk for each bucket. Cloud also setsFILESYSTEM_DISKto your default bucket. Buckets don’t need a Cargo feature. - WebSockets: When you attach a Laravel Reverb cluster, Cloud sets
BROADCAST_CONNECTION=reverband theREVERB_*variables your application needs. - Email: When you attach email, Cloud sets
MAIL_MAILER=resendand the Resend variables. - Inertia SSR: When editing your App cluster, toggle on the Use Inertia SSR option, then save and redeploy. Cloud builds your assets with
npm run build:ssr, runs the SSR server alongside your application, and setsINERTIA_SSR=true.
Logging
Cloud setsLOG_CHANNEL=laravel-cloud-socket, so your application’s logs, scheduled command output, and reported errors stream to your environment’s logs with their levels. Set LOG_LEVEL to change which levels Laravel Rust records. It defaults to info.
Issues doesn’t capture errors from Laravel Rust applications yet. Errors your application reports appear in your logs.
