Getting started with Laravel Rust
Install the new Laravel CLI, create your first app, pick a database and run it locally, with notes for anyone coming from Laravel PHP.
- getting-started
- cli
If you’ve shipped Laravel apps for years, most of this setup will feel familiar: laravel new still creates the project, secrets still live in .env, and migrations still come first. What’s new is the Rust toolchain, and a laravel command that takes over the job of php artisan.
Three things to install first
- Rust, version 1.99 or newer. rustup installs and updates it (
rustup updateif you already have it). - Node.js LTS, for the frontend build.
- Git.
You won’t need PHP or Composer for this app.
The CLI
The installer is a one-liner. macOS and Linux:
curl -fsSL https://laravel.com/install.sh | sh
Windows (PowerShell):
powershell -ExecutionPolicy Bypass -c "irm https://laravel.com/install.ps1 | iex"
It drops laravel into ~/.laravel/bin and puts that folder on your PATH. Open a fresh terminal so the change takes effect.
Tip: two commands, one name. Herd and the old Composer installer also ship a
laravelbinary. Runlaravel --version: the right one printsLaravel CLIand a version number. If you see something else, move~/.laravel/binearlier in yourPATH.
Create the app
laravel new parcel-tracker --rust
cd parcel-tracker
The name is only an example; here it’s a service that follows deliveries across couriers. Use your own.
Without --rust the CLI asks which language you want. Either way it fetches the starter, writes .env with a fresh APP_KEY, installs the npm packages and compiles the app. The frontend arrives wired up: Inertia, React, TypeScript, Tailwind and Vite Plus.
Tip: the library is
app, whatever the folder is called. Paths into your code start withapp::, even in a project namedparcel-tracker(inside the library itself, plain Rustcrate::works as well). The project name is thenameunder[package]inCargo.toml.
Pick a database
Out of the box the app expects PostgreSQL on your machine, with a database called laravel:
DB_CONNECTION=postgres
DATABASE_URL=postgres://postgres@127.0.0.1/laravel
For a weekend project, SQLite is less to set up. Drivers are Cargo features, so open Cargo.toml, swap database-postgres for database-sqlite on the laravel-rust dependency, and point .env at a file:
DB_CONNECTION=sqlite
DATABASE_URL=sqlite://storage/app/parcel-tracker.sqlite?mode=rwc
The ?mode=rwc part lets SQLite create the file the first time it connects. (MySQL works the same way, with database-mysql.) For an app you plan to deploy, develop on the database you’ll run in production.
Now create the tables:
laravel migrate
The starter migrations add users, sessions and the queue tables. If the database itself is missing, migrate offers to create it.
Start everything with one command
laravel dev
Visit http://127.0.0.1:8000. Edit a Rust file or .env and the app rebuilds, restarts, and refreshes your browser once it’s back up.
Commands you’ll type every day
| You used to type | Now you type |
|---|---|
php artisan migrate |
laravel migrate |
composer run dev |
laravel dev |
php artisan route:list |
laravel route:list |
php artisan list |
laravel list |
Run them from any folder inside the project. The CLI compiles the app before running a command and stays quiet about it unless the build fails.
A short checklist for later
When the app is ready to go online:
- Build assets with
npm run buildand the app withcargo run --release. - Set
APP_ENV=productionandAPP_DEBUG=false. Debug error pages reveal details about your app to whoever triggers them. - Health checks can hit
/up, which answers200once the app has booted. It’s registered insrc/app.rs.