21 / 35

Meet Laravel Rust· 10 min read· Lesson 21 of 35

Creating your first Laravel Rust app

Part 2 · Laravel Rust. Install the Laravel CLI, create the Rusty Bean Café app, set up a database and see it running in your browser.

In the last lesson you met Laravel Rust. Now you’ll install it and get the Rusty Bean Café website running on your own computer. By the end you’ll have a real web app at http://127.0.0.1:8000, rebuilding itself every time you save a file.

Every command in this lesson comes from the official Laravel Rust installation guide (opens in new tab). If something looks different on your machine, that page is the source of truth.

What you need first

Laravel Rust needs three tools:

  1. Rust 1.99 or later. You installed Rust in Installing Rust.
  2. Node.js (the LTS, or “long-term support”, release). Your app’s front end, the part that runs in the browser, is built with JavaScript tools that run on Node.js.
  3. Git, which most computers already have.

If you installed Rust a while ago, update it:

Terminal window
rustup update

This downloads the latest stable Rust. Check the version with rustc --version. It should say 1.99 or higher.

If you don’t have Rust at all, the official installer for macOS and Linux is:

Terminal window
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

On Windows, download the installer from rustup.rs (opens in new tab) instead. For Node.js, grab the LTS installer from the Node.js download page (opens in new tab).

Install the Laravel CLI

A CLI (command-line interface) is a program you run by typing commands in your terminal. The Laravel CLI creates new apps and runs your app’s commands.

On macOS and Linux:

Terminal window
curl -fsSL https://laravel.com/install.sh | sh

On Windows, in PowerShell:

Terminal window
powershell -ExecutionPolicy Bypass -c "irm https://laravel.com/install.ps1 | iex"

Step by step:

  1. curl -fsSL ... downloads Laravel’s install script.
  2. | sh (or | iex on Windows) runs it.
  3. The script puts the laravel command in ~/.laravel/bin and adds that folder to your PATH, the list of folders your terminal searches for commands.

Open a new terminal window so it picks up the new PATH, then check the install:

Terminal window
laravel --version

The output should start with Laravel CLI.

Warning

If you’ve used PHP Laravel before, you may already have an older laravel command from Laravel Herd or Composer. If laravel --version doesn’t start with Laravel CLI, the old one is being found first. Run which -a laravel (macOS/Linux) to list every laravel on your system, then move the ~/.laravel/bin line in your shell profile (such as ~/.zshrc) below the Herd or Composer lines. The installation guide (opens in new tab) has the full steps.

Create the café app

Go to the folder where you keep your projects and run:

Terminal window
laravel new rusty-bean
cd rusty-bean

laravel new asks which language you’d like to use. Choose Rust. To skip the question, for example in a script, pass the --rust flag:

Terminal window
laravel new rusty-bean --rust

Behind the scenes, the CLI:

  1. Downloads a fresh app into a rusty-bean folder.
  2. Creates a .env file for your settings.
  3. Installs the front-end dependencies (your app comes with Inertia, React, TypeScript, Tailwind and Vite Plus).
  4. Compiles the app, so the first run starts right away.

The first compile can take a few minutes because Cargo builds every dependency from source. Grab a coffee, it’s on theme.

Your secret key

The CLI also creates an encryption key and saves it as APP_KEY in .env. Laravel uses it to lock your cookies and sessions so nobody can tamper with them.

Important

.env holds secrets such as APP_KEY and database passwords. Never commit it to Git or share it. Your new app’s .gitignore already leaves it out.

One more detail: whatever you name your project, its library is always called app. So when you import your own code, the paths start with app::, as in use app::models::User.

Set up a database

A database is where your app stores its data permanently: users, menu items, orders. Even a brand-new app needs one, because it keeps logged-in users and background jobs there.

New apps expect PostgreSQL, a popular database server. Your .env file starts with these lines:

.env
DB_CONNECTION=postgres
DATABASE_URL=postgres://postgres@127.0.0.1/laravel

These mean: “use PostgreSQL, running on this computer, with a database called laravel.” If you don’t have PostgreSQL yet, DBngin (opens in new tab) (macOS and Windows) or Postgres.app (opens in new tab) (macOS) can start one in a few clicks. Laravel recommends developing with the same database you’ll use in production.

The SQLite option

Prefer not to run a database server while you learn? Laravel Rust also supports SQLite, which keeps the whole database in one file. Two changes:

  1. In Cargo.toml, find the laravel-rust dependency and replace its database-postgres feature with database-sqlite.
  2. Point .env at a file:
.env
DB_CONNECTION=sqlite
DATABASE_URL=sqlite://storage/app/database.sqlite?mode=rwc

The ?mode=rwc part tells SQLite to create the file the first time your app connects (rwc stands for read, write, create).

Run the migrations

Migrations are Rust files that describe how to build your database tables. You’ll write your own in Migrations and the schema builder. For now, run the ones that come with the app:

Terminal window
laravel migrate

This creates the users, sessions and queue tables. If the database doesn’t exist yet, migrate offers to create it.

Run the app

Now the fun part:

Terminal window
laravel dev

laravel dev starts three things at once:

  1. Your web server, the Rust program that answers requests.
  2. A queue worker, which runs background jobs (more on those in Queued jobs).
  3. Vite Plus, which serves your front-end files and reloads them as you edit.

Open your browser at http://127.0.0.1:8000 and you’ll see the welcome page. 127.0.0.1 means “this computer”, and 8000 is the port, like a door number on your machine.

Leave laravel dev running while you work. When you save a change to your Rust code or .env, the app rebuilds and restarts, and the browser refreshes once it’s back. Edits to front-end files hot-reload immediately. To stop it, press Ctrl+C in the terminal.

Tip

Rust rebuilds take a few seconds, unlike PHP where you just refresh. If the page seems stuck, look at the terminal running laravel dev. A compiler error there means the new version didn’t build, and the error tells you what to fix.

Ask your app what it can do

Your app has its own console commands, and you run them through laravel from anywhere inside the project. Try listing every route:

Terminal window
laravel route:list

You’ll see each URL your app answers, its HTTP method and the handler behind it. One route worth spotting is /up, the health check. It answers 200 (meaning “OK”) once your app has started, so hosting services can check that it’s alive.

To see every available command:

Terminal window
laravel list

If you’re ever somewhere without the laravel CLI installed, you can run the same commands through Cargo:

Terminal window
cargo run -- route:list

The -- tells Cargo “everything after this goes to my program, not to Cargo.”

Try it yourself

  1. With laravel dev running, visit http://127.0.0.1:8000/up in your browser. What do you see? Then run laravel route:list in a second terminal and find the /up route.
  2. Without looking back, write down the four commands that take you from “nothing installed except Rust” to “café app running in my browser” (assume PostgreSQL is already running).
Show solution
  1. /up answers with status 200, which means the app is healthy. Don’t expect a pretty page. This route is meant for load balancers and uptime monitors, not people. In laravel route:list you’ll find /up alongside the welcome page.
  2. In order:
Terminal window
curl -fsSL https://laravel.com/install.sh | sh
laravel new rusty-bean --rust
laravel migrate
laravel dev

(Remember to open a new terminal after installing the CLI, and to cd rusty-bean before laravel migrate.)

Recap

  • Laravel Rust needs Rust 1.99+, Node.js and Git. The Laravel CLI installs with one command.
  • laravel new rusty-bean (choose Rust, or pass --rust) creates, configures and compiles a new app.
  • .env holds your settings and secrets, including APP_KEY. Never commit it.
  • New apps use PostgreSQL by default, and SQLite works too. laravel migrate creates the starter tables.
  • laravel dev runs the server, a queue worker and Vite together at http://127.0.0.1:8000. laravel route:list shows your routes.

What’s next

Your app is running, but what are all those folders? In Project structure we’ll tour the project so you know where every part of the café lives.

0 of 35 lessons complete

Search lessons

Type to search all lessons.