> ## Documentation Index
> Fetch the complete documentation index at: https://cloud.laravel.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel Rust deploy guide

> Configure your Laravel Rust application for production on Laravel Cloud.

The [Laravel Rust quickstart](https://cloud.laravel.com/docs/quickstart.md#laravel-rust) walks you through your first deployment to Laravel Cloud. Once your application is up and running, this guide helps you get it ready for production. We'll cover how Cloud builds and runs your application, and how to connect databases, caches, queues, and the other resources your application uses.

Laravel Rust is the Rust implementation of the Laravel framework. Cloud recognizes Laravel Rust applications and configures them for you, so you don't need the port, shutdown, or logging code described in the [Rust deploy guide](https://cloud.laravel.com/docs/deploy-guides/rust.md).

## Build your application

### Detection

Cloud detects a Laravel Rust application from the `laravel-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](https://cloud.laravel.com/docs/environments.md#build-commands) to compile your frontend assets, then your application:

```sh theme={"theme":{"light":"min-light","dark":"material-theme-palenight"}}
npm ci --audit false
npm run build

cargo build --release
```

Cloud copies the executables from your release output into `/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 your `laravel-rust` dependency enables a feature for each resource attached to your environment:

| Resource | Cargo feature |
| - | - |
| [Laravel MySQL](https://cloud.laravel.com/docs/resources/databases/laravel-mysql.md) or Amazon RDS for MySQL | `database-mysql` |
| [Serverless Postgres](https://cloud.laravel.com/docs/resources/databases/postgres.md) or Amazon RDS for PostgreSQL | `database-postgres` |
| [Laravel Valkey](https://cloud.laravel.com/docs/resources/caches/valkey.md) or another cache | `redis` |
| [Managed queue](https://cloud.laravel.com/docs/queues.md) | `sqs` |

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`:

```toml theme={"theme":{"light":"min-light","dark":"material-theme-palenight"}}
[dependencies]
laravel-rust = { version = "0.1", features = ["database-mysql", "redis", "sqs"] }
```

## 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 an `APP_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](https://cloud.laravel.com/docs/health-checks.md) 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 no `artisan` 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:

```sh theme={"theme":{"light":"min-light","dark":"material-theme-palenight"}}
example-app migrate:status
```

You may run commands from your environment's [**Commands** tab](https://cloud.laravel.com/docs/environments.md#commands), or use them in your deploy commands and [background processes](https://cloud.laravel.com/docs/workers.md).

### Run migrations

New environments include a commented-out [deploy command](https://cloud.laravel.com/docs/environments.md#deploy-commands) that runs your migrations:

```sh theme={"theme":{"light":"min-light","dark":"material-theme-palenight"}}
# /var/www/bin/example-app migrate --force
```

When you attach a database, Cloud uncomments this command so your migrations run on every deployment. If you have changed your deploy commands, add the command yourself. The `--force` option skips the confirmation that Laravel Rust asks for in production.

## Databases and caches

When you attach a database, Cloud sets the `DATABASE_URL` environment variable, and Laravel Rust chooses its driver from the URL. Make sure your `laravel-rust` dependency enables the [matching Cargo feature](#cargo-features).

When you attach a cache, such as [Laravel Valkey](https://cloud.laravel.com/docs/resources/caches/valkey.md), 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](https://cloud.laravel.com/docs/queues.md). When you attach a managed queue, Cloud sets `QUEUE_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](https://cloud.laravel.com/docs/workers.md). 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's `schedule:work` command, which runs your due tasks every minute. When your environment [scales to zero](https://cloud.laravel.com/docs/compute.md#scale-to-zero), Cloud wakes it to run scheduled tasks.

## Other resources

* **Object storage:** When you attach a [bucket](https://cloud.laravel.com/docs/resources/object-storage.md), Cloud sets `LARAVEL_CLOUD_DISK_CONFIG`, and Laravel Rust adds a disk for each bucket. Cloud also sets `FILESYSTEM_DISK` to your default bucket. Buckets don't need a Cargo feature.
* **WebSockets:** When you attach a [Laravel Reverb](https://cloud.laravel.com/docs/resources/websockets.md) cluster, Cloud sets `BROADCAST_CONNECTION=reverb` and the `REVERB_*` variables your application needs.
* **Email:** When you attach [email](https://cloud.laravel.com/docs/resources/email.md), Cloud sets `MAIL_MAILER=resend` and 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 sets `INERTIA_SSR=true`.

## Logging

Cloud sets `LOG_CHANNEL=laravel-cloud-socket`, so your application's logs, scheduled command output, and reported errors stream to your environment's [logs](https://cloud.laravel.com/docs/logs.md) with their levels. Set `LOG_LEVEL` to change which levels Laravel Rust records. It defaults to `info`.

[Issues](https://cloud.laravel.com/docs/issues.md) doesn't capture errors from Laravel Rust applications yet. Errors your application reports appear in your logs.
