# Laravel

> What a Laravel app needs: APP_KEY and trusted proxies, how it is recognised, Composer and Vite, Octane, Inertia SSR, a Postgres database, queues and the scheduler.

A Laravel app runs on PHP 8.2, 8.3 or 8.4 behind FrankenPHP, with its Composer packages and its built assets. Blade, Livewire, Inertia with React or Vue (with or without server-side rendering), Octane and an API without a front end all run; the starter kits run as they come.

> **Add APP_KEY and trust the proxy before the first deployment**
>
> Run `php artisan key:generate --show` on your machine and add the value under **Variables** as `APP_KEY`. In `bootstrap/app.php`, trust the platform's proxy with `$middleware->trustProxies(at: '*');`, so links are `https` and `request()->ip()` is the visitor.

````text
Check whether the Laravel app in this repository can run on Orbit (hosting for Node.js and Laravel apps, https://arrangic.com) and help me make it ready.

How to work

1. Start with a dry run. Read the code and report. Do not change, create or delete any file, and do not install, build or start the app.
2. Before you read, run "git status". If there are uncommitted changes already, tell me, so that your changes and mine stay apart.
3. After the report, ask which fixes to apply and wait for my answer. Apply only the fixes I confirm, each with the smallest change that works. No refactoring, no reformatting, no new packages unless the package is the fix.
4. Never commit, push, stash, reset or switch branches. Leave every change uncommitted, so I can look at it and decide what to keep.
5. Never show the value of a secret. Name the variable only.
6. If you are not sure, say "not sure" and how I can check. Do not guess.
7. Keep answers short and plain: one or two lines for each point, no introduction, no account of what you read.

What the platform expects

The project
- This is a Laravel app (PHP 8.2, 8.3 or 8.4). If it is something else, say so and stop: https://arrangic.com/docs/check-your-app has the prompt that finds the framework.
- The dashboard reads composer.json when the app is created: composer.json with "laravel/framework" in require is Laravel, read before package.json, so a Laravel app with React or Vue pages is Laravel. The framework cannot be changed after the app is created.
- composer.json and composer.lock are at the top of the repository, or in one folder that I set as the root directory. The lockfile is committed and matches composer.json.
- The repository is at most 1 GB. A Dockerfile is ignored.
- PHP extensions available: apcu, bcmath, calendar, ctype, curl, dom, ev, excimer, exif, fileinfo, ftp, gd, gettext, gmp, iconv, igbinary, imagick, imap, intl, json, ldap, mbstring, mongodb, msgpack, mysqli, openssl, opcache, pcntl, pdo_mysql, pdo_pgsql, pdo_sqlite, pdo_sqlsrv, posix, pspell, redis, session, shmop, simplexml, soap, sockets, sodium, sqlite3, sqlsrv, tokenizer, xml, xsl, zip, zlib. No other extension and no system packages can be added. Name any other extension the code needs.
- PHP settings: memory_limit 256M, upload_max_filesize and post_max_size 64M, max_execution_time 60, OPcache on.

Install and build
- The PHP version is read from "php" in composer.json: a floor such as ^8.2 gets 8.4, a pinned minor such as 8.3.* gets 8.3. Node.js 18, 20, 22 or 24 (24 when nothing is said) builds the assets; the version is read from .nvmrc, then "engines.node".
- Install command: "composer install --no-dev --optimize-autoloader --no-interaction && npm ci" (pnpm or Yarn after the lockfile; only Composer without a package.json). Composer's scripts run (package discovery). No devDependencies of Composer are installed, so whatever the running app needs is in "require".
- Build command: "npm run build:ssr" if package.json has that script, otherwise "npm run build" if it has a build script, otherwise none. node_modules is removed after the build unless the start command runs Inertia's rendering process. A build may take 30 minutes.
- A variable is a Config variable or a secret. Every Config variable reaches the install, the build, the deploy commands, workers and the running app as an environment variable; a secret reaches all of them except the install and the build. A .env file that is not committed is not there. Tell me which variables the code reads (config files, env() calls).

Starting
- Start command: "php artisan optimize && frankenphp php-server --root public --listen 127.0.0.1:$PORT". With laravel/octane in require: "php artisan optimize && php artisan octane:frankenphp --host=127.0.0.1 --port=$PORT". With a build:ssr script: "php artisan optimize && { php artisan inertia:start-ssr & <the server>; }". The platform's proxy sits in front and answers on the app's hostnames; the app listens on 127.0.0.1 and the port in PORT (8000 unless I change it). "php artisan optimize" runs at start, with the real variables, never in the build.
- Inertia server-side rendering needs the SSR entry (resources/js/ssr.jsx or ssr.ts) and pages that do not read window while their module loads; otherwise the pages render in the browser.
- Deploy command: "php artisan migrate --force", run once per deployment on a machine of its own before the new version takes traffic, for up to 15 minutes.
- Trusted proxies: "$middleware->trustProxies(at: '*')" in bootstrap/app.php, so request()->ip() is the visitor, isSecure() is true and url() is https. The visitor's address is also in the X-Real-IP header.
- Health check path: /up, set in the dashboard; the new version takes traffic only once it answers.
- It has to be listening within 2 minutes. HTTPS is done by the platform. To stop the app the platform sends SIGTERM and waits 30 seconds.

While it runs
- The app and the deploy commands run without root rights, as one user, and can write in the folder of the app, in the home folder and in /tmp. storage and bootstrap/cache are writable. public/storage is linked to storage/app/public by the platform; a custom link in config/filesystems.php needs "php artisan storage:link" in the build command.
- Each replica has its own temporary disk and memory: SQLite files, uploads and the "file" session and cache drivers do not reach another replica and are lost on a deployment. Sessions, the cache and the queue belong in a database or a Valkey cache of the team (a resource in the dashboard, Redis-compatible: REDIS_URL, REDIS_HOST, REDIS_PORT, REDIS_USERNAME and REDIS_PASSWORD reach the app once attached; full, it refuses writes unless its eviction policy drops keys: keep noeviction for the queue and sessions, allkeys-lru suits a cache store of its own) that the replicas share; files in a bucket. Name every driver set to file, sync or sqlite.
- The database: a Postgres database of the team (Postgres 17, 18 or 19 as picked when it is created, 18 unless another is picked; powered by Neon, a resource in the dashboard). Once attached, the platform sets DB_CONNECTION (pgsql), DB_URL, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DATABASE_URL and PGCHANNELBINDING (require): the pgsql connection Laravel ships reads them, nothing to change in config/database.php and no DB_* variables to add. Migrations run with "php artisan migrate --force" on the direct host the app gets. The database sleeps when nothing is connected: "php artisan schedule:work" with every-minute tasks, or a queue worker or the cache on the database driver, keep it awake all month, so suggest the redis queue and cache with a Valkey cache. Name a MySQL- or SQLite-only query or package.
- An idle app sleeps and wakes only for a request. The scheduler and the queue need a worker: "php artisan queue:work --tries=3 --max-time=3600", "php artisan horizon", "php artisan schedule:work", each a command set in the dashboard, run on a machine of its own with the app's variables, started again when it stops, given SIGTERM and 10 to 300 seconds to finish. "php artisan schedule:run" every 5 minutes fits a cron job of the dashboard. Name such work and suggest a worker or a cron job.
- Not yet: Reverb (it needs a server of its own) and "php artisan down" across replicas. Say so when the code depends on one.
- Variable names are capital letters, digits and underscores. PORT, NODE_ENV, APP_ENV (production), LOG_CHANNEL (stderr) and OCTANE_SERVER (frankenphp) are set by the platform; a variable of mine with the same name takes its place. APP_KEY has to be added before the first deployment. The platform does not set APP_URL: if the code reads it, I add it in the dashboard with the address of the app.

The report

First line, one of:
Result: ready
Result: ready after N fixes
Result: not supported yet

Then up to three lists. Number the fixes in one sequence across the lists. Leave out a list that would be empty.

Must fix (it does not build or start without this)
1. What is wrong, in a few words (file:line)
   Fix: the change, in one line

Should fix (it starts, but something breaks in use)
2. What is wrong, in a few words (file:line)
   Fix: the change, in one line

Set in the dashboard (no code change)
- Node version, port, root directory, build command, start command: only where the platform would not pick the right one by itself
- Variables to add: names only
- Keep one replica always on: only if the app runs jobs
- Concurrent requests per replica: only if the app holds sockets open, the number of people connected at once per replica
- Health check path: only if the app has a route that answers with a status under 400 once it is ready (/health, for example), that path

Last line, exactly:
Apply fixes? Answer "all", the numbers (for example "1, 3"), or "none".

After I answer

Apply the confirmed fixes. Then tell me, briefly:
- each file you changed and what changed in it
- that nothing is committed: "git diff" shows the changes and "git restore <file>" undoes one
- the "Set in the dashboard" list again

More on every rule: https://arrangic.com/llms.txt
Prompt version: 2026-11-21
````

## The short list

| Your app needs | How |
| --- | --- |
| A `composer.json` | With `laravel/framework` in `require`, at the top of the repository or in the folder you set as the root directory, with its `composer.lock` |
| `APP_KEY` | A variable, made with `php artisan key:generate --show` |
| Trusted proxies | `$middleware->trustProxies(at: '*')` in `bootstrap/app.php` |
| A database, cache and session store off the disk | A [Postgres database](#a-postgres-database) and a [Valkey](https://arrangic.com/docs/redis.md) cache of the team, or a database of your own: the `file` drivers and SQLite live on one machine only |
| A quick start | Be listening within 2 minutes |

[Check your app](https://arrangic.com/docs/check-your-app.md) checks all of these for you.

## How it is recognised

With `laravel/framework` in `require` of `composer.json`, the dashboard picks **Laravel** when you create the app and fills in the commands below. `composer.json` is read before `package.json`: a Laravel app with React or Vue pages is a Laravel app. A framework you pick by hand stays, and the framework cannot be changed after the app is created. See [How the framework is chosen](https://arrangic.com/docs/frameworks.md#how-the-framework-is-chosen).

The PHP version comes from `php` in `require`: `^8.2` gets the newest the platform runs (8.4), `8.3.*` gets 8.3. It is a setting under **Settings**, **Build & deploy**, next to the Node version, which builds the assets.

## Build and start

| Command | Filled in with |
| --- | --- |
| Install | `composer install --no-dev --optimize-autoloader --no-interaction && npm ci` (`pnpm install` or `yarn install` after your lockfile; the npm part is left out without a `package.json`) |
| Build | `npm run build:ssr` when `package.json` has that script, otherwise `npm run build` when it has a build script, otherwise nothing |
| Start | `php artisan optimize && frankenphp php-server --root public --listen 127.0.0.1:$PORT` |
| Deploy command | `php artisan migrate --force` |

The start command writes the caches from the variables the app runs with, then serves `public` on the port in `PORT`. The platform's own proxy sits in front of it and answers on the app's hostnames.

**Octane.** With `laravel/octane` in `require`, the start command is `php artisan optimize && php artisan octane:frankenphp --host=127.0.0.1 --port=$PORT`. `OCTANE_SERVER=frankenphp` is set by the platform.

**Inertia with server-side rendering.** With a `build:ssr` script, the build makes the pages and the rendering bundle, and the start command runs Inertia's rendering process next to the server: `php artisan optimize && { php artisan inertia:start-ssr & frankenphp php-server --root public --listen 127.0.0.1:$PORT; }`. The running app then keeps `node_modules` for that process. The SSR entry (`resources/js/ssr.jsx` or `resources/js/ssr.ts`) has to exist, and a page must not read `window` while its module loads. Without that script the pages render in the browser.

**What the running app carries.** The files of your repository, `vendor` without the dev packages, and the built assets in `public/build`. `node_modules` is taken out after the build, unless the start command runs Inertia's rendering process. `public/storage` is linked to `storage/app/public` for you: no `php artisan storage:link` needed. A link you add to `links` in `config/filesystems.php` still needs that command in the build command.

## Variables

The [variables](https://arrangic.com/docs/environment-variables.md) you add reach the app as environment variables, the build included. The platform sets three for Laravel, next to `PORT` and `NODE_ENV`:

| Variable | Value |
| --- | --- |
| `APP_ENV` | `production` |
| `LOG_CHANNEL` | `stderr`, so the log is on the [Logs](https://arrangic.com/docs/logs.md) page |
| `OCTANE_SERVER` | `frankenphp` |

A variable of your own with the same name takes their place. Add `APP_KEY`, and `APP_URL` with the address of the app if your code reads it. An attached [Postgres database](#a-postgres-database) adds the `DB_*` variables, and a [Valkey cache](https://arrangic.com/docs/redis.md) the `REDIS_*` ones.

## A Postgres database

Create one under **Resources**, **New Postgres database**, in the region of the app, then **Attach to an app** on its page with the prefix `DB`. The platform sets the variables Laravel reads, with the next redeploy:

| Variable | Value |
| --- | --- |
| `DB_CONNECTION` | `pgsql` |
| `DB_URL` | The connection URL, with `sslmode=require&channel_binding=require` |
| `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` | The same connection in parts |
| `PGCHANNELBINDING` | `require`, so the `pgsql` driver binds the sign-in to TLS too |

Nothing to change in `config/database.php`: the `pgsql` connection Laravel ships reads them, and `pdo_pgsql` is in the [extensions](#php). Do not add `DB_*` variables of your own for it. The default `php artisan migrate --force` deploy command runs the migrations before each new version takes traffic.

The app gets the direct host, which migrations need, because they keep a session. Leave it there unless the database runs out of connections; then put the **Pooled URL** from the database's page in a variable of your own for the app's queries, and keep the migrations on `DB_URL`. See [Pooled or direct](https://arrangic.com/docs/postgres.md#pooled-or-direct).

**The database sleeps when idle, unless something keeps querying it.** `php artisan schedule:work` running a task every minute, or a queue worker on the `database` driver that polls for jobs every few seconds, never lets it sleep, and its compute then runs all month. Put the queue and the cache in a [Valkey cache](https://arrangic.com/docs/redis.md) (`QUEUE_CONNECTION=redis`, `CACHE_STORE=redis`), since the scheduler's locks live in the cache, and the database sleeps when the app does. A schedule that queries the database itself every minute keeps it awake all the same. See [Sleep when idle](https://arrangic.com/docs/postgres.md#sleep-when-idle).

## PHP

| Setting | Value |
| --- | --- |
| `memory_limit` | 256M |
| `upload_max_filesize`, `post_max_size` | 64M |
| `max_execution_time` | 60 seconds |
| OPcache | On |

Extensions: apcu, bcmath, calendar, ctype, curl, dom, ev, excimer, exif, fileinfo, ftp, gd, gettext, gmp, iconv, igbinary, imagick, imap, intl, json, ldap, mbstring, mongodb, msgpack, mysqli, openssl, opcache, pcntl, pdo_mysql, pdo_pgsql, pdo_sqlite, pdo_sqlsrv, posix, pspell, redis, session, shmop, simplexml, soap, sockets, sodium, sqlite3, sqlsrv, tokenizer, xml, xsl, zip, zlib. The list is fixed: an extension that is not on it cannot be added per app.

## A health check path

Laravel answers `/up`. Set it as the [health check path](https://arrangic.com/docs/deployments.md#health-check) under **Settings**, and the new version takes traffic only once the app answers there.

## The visitor's address

With the proxy trusted, Laravel reads the visitor's address and the scheme the usual way:

```php
$visitor = $request->ip();
$secure = $request->isSecure(); // true
```

The address is also in the `X-Real-IP` header. See [The visitor's address](https://arrangic.com/docs/requests.md#the-visitors-address).

## Queues, the scheduler and one-off commands

- **Queue workers** are [workers](https://arrangic.com/docs/workers.md): `php artisan queue:work --tries=3 --max-time=3600`, or `php artisan horizon` with Horizon, each on a machine of its own with the app's variables. A queue needs a database or a [Valkey](https://arrangic.com/docs/redis.md) cache the web replicas and the workers share; on a Postgres database a worker that polls it keeps it awake.
- **The scheduler** is a worker too: `php artisan schedule:work`. Or a [cron job](https://arrangic.com/docs/cron-jobs.md) that runs `php artisan schedule:run` every 5 minutes, when every-minute tasks do not matter.
- **One-off commands** run as [deploy commands](https://arrangic.com/docs/deploy-commands.md) before each new version, or as a cron job's **Run now**.

## Everything else

- **Disk, memory, stopping, crashes.** Each replica has its own temporary disk: uploads, SQLite files and the `file` session and cache drivers do not reach another replica or survive a deployment. Keep sessions and the cache in a [Postgres database](#a-postgres-database) or a [Valkey](https://arrangic.com/docs/redis.md) cache, and files in a bucket. The app runs without root rights and is stopped with `SIGTERM`. See [The running app](https://arrangic.com/docs/running-app.md).
- **Deploy commands and cron jobs** run from the same image as the app, in its folder, so `php artisan` commands work as they are. See [Deploy commands](https://arrangic.com/docs/deploy-commands.md) and [Cron jobs](https://arrangic.com/docs/cron-jobs.md).
- **Timers.** An idle app sleeps. Work without a visitor belongs in a worker or a cron job. See [Sleep and wake](https://arrangic.com/docs/sleep-and-wake.md).
- **Requests.** HTTPS, the hostnames the app answers on and how many requests a replica takes at once: [Requests and sockets](https://arrangic.com/docs/requests.md).
- **Coming soon.** Reverb (it needs a server of its own) and `php artisan down` across replicas.

---

This page on the site: https://arrangic.com/docs/frameworks/laravel  
All pages of the documentation: https://arrangic.com/llms.txt
