Installation
Meet Laravel
Laravel for Rust is currently in beta. Releases before 1.0 may include breaking changes to APIs and configuration.
Laravel for Rust is a full-stack web application framework. It includes the routing, middleware, sessions, database tools, queues, and testing helpers that every web application needs, so you can spend your time on what your application does.
Laravel is built on Axum and Tokio, which give it a solid, fully asynchronous foundation: a handful of threads can serve thousands of concurrent requests, and a request waiting on the database or another service never holds up the rest. On that foundation, Laravel adds a variety of full-stack features for building ambitious applications, from authentication and validation to queues, mail, notifications, and broadcasting.
Creating an application
Before you create your first Laravel application, install Rust, Node.js, and Git on your machine.
Laravel needs Rust 1.99 or later. If you don't have Rust yet, install it with rustup, Rust's official installer:
1curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh1curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
On Windows, download the installer from rustup.rs instead. If you already have Rust, run rustup update to get the latest stable release.
Your application's frontend is built with Node.js. Download the LTS release from the Node.js website, which offers graphical installers for macOS and Windows. Most machines already have Git. If yours doesn't, download it from the Git website.
Installing the Laravel CLI
The Laravel CLI creates new applications and runs your application's commands. On macOS and Linux, install it with this command:
1curl -fsSL https://laravel.com/install.sh | sh1curl -fsSL https://laravel.com/install.sh | sh
On Windows, run this command in PowerShell instead:
1powershell -ExecutionPolicy Bypass -c "irm https://laravel.com/install.ps1 | iex"1powershell -ExecutionPolicy Bypass -c "irm https://laravel.com/install.ps1 | iex"
The installer puts the laravel command in ~/.laravel/bin and adds that directory to your PATH, so open a new terminal before you use it. When a newer version of the CLI comes out, laravel new tells you and offers to update it for you.
Resolving PATH conflicts
Laravel Herd and the older Composer-based Laravel installer also provide a laravel command. If you have either installed, open a new terminal and check which binary your shell finds first:
1laravel --version1laravel --version
The output should start with Laravel CLI. If it prints a different installer's version, another directory appears ahead of ~/.laravel/bin on your PATH. You can inspect every laravel binary on your PATH by running which -a laravel on macOS and Linux, or Get-Command laravel -All in PowerShell on Windows.
To put the new Laravel CLI first on macOS and Linux, move the PATH line the installer added to your shell profile (such as ~/.zshrc or ~/.bashrc) below any Herd or Composer PATH entries. If you installed the older installer with Composer and no longer need it, you may also remove it with composer global remove laravel/installer. On Windows, move %USERPROFILE%\.laravel\bin above Herd's or Composer's directory in your user Path environment variable. Then open a new terminal and run laravel --version again to confirm.
Creating your application
Now create your application with laravel new. When it asks which language you'd like to use, choose Rust. If you'd rather skip the question, such as in a script, pass --rust:
1laravel new example-app2cd example-app1laravel new example-app2cd example-app
The CLI downloads a new application into the example-app directory, creates its .env file, installs its frontend dependencies, and compiles it, so your first command starts right away. Your new application comes set up with Inertia, React, TypeScript, Tailwind, and Vite Plus.
The CLI also generates your application's encryption key and sets it as APP_KEY in .env. This key encrypts your cookies and sessions, so keep it secret. To change it later, follow the key rotation guide.
Your .env file holds the settings that change between your machine and your servers, such as database URLs and API keys. Since it holds your secrets, don't commit it to source control. The configuration guide covers .env and the config files in src/config/.
Your application's library is always named app, whatever you call your project, so your imports start with app::. To rename your project, change the name in the [package] section of Cargo.toml.
Databases and migrations
Your application stores its users, queued jobs, and other data in a database, so set one up before you start the application. New applications default to PostgreSQL, and we recommend developing against the same database you plan to run in production so your queries, migrations, and tests behave the same way. By default, your .env file connects to a local PostgreSQL database named laravel:
1DB_CONNECTION=postgres1DB_CONNECTION=postgres
If you don't have PostgreSQL installed locally yet, DBngin (macOS and Windows) and Postgres.app (macOS) let you start a local PostgreSQL server in a few clicks.
You may change these defaults to suit your database. The database guide covers these settings in detail. Then run your migrations from your application's directory to create the users, sessions, and queue tables:
1laravel migrate1laravel migrate
If the database doesn't exist yet, migrate offers to create it.
You may use SQLite or MySQL instead. In Cargo.toml, replace the database-postgres feature on laravel-rust with database-sqlite or database-mysql. Then point .env at your database:
1DB_CONNECTION=sqlite2DATABASE_URL=sqlite://storage/app/database.sqlite?mode=rwc1DB_CONNECTION=sqlite2DATABASE_URL=sqlite://storage/app/database.sqlite?mode=rwc
The ?mode=rwc option tells SQLite to create the file the first time your application connects. Your application's migrations work on every supported database.
Running the application
Next, start your application with laravel dev, which starts your application, a queue worker, and Vite Plus all at once:
1laravel dev1laravel dev
Once the application starts, visit http://127.0.0.1:8000 in your browser to see its welcome page. When you change your Rust code or .env file, your application rebuilds and restarts, and the page in your browser refreshes once the server is back.
While Vite runs, your frontend edits appear in the browser through hot reloading, and the page refreshes when you edit a template in resources/views/.
Your application has console commands of its own, such as route:list, which lists your routes. Run them through laravel from your application's directory or any directory inside it. The CLI compiles your application first, and only shows the compiler's output when the build fails:
1laravel route:list1laravel route:list
To see every command your application has, run laravel list.
To check your frontend's formatting, lint rules, and types, run npm run check. To apply the fixes it can make, run npm run check:fix.
Running in production
When you're ready to see how your application runs in production, stop Vite, build your frontend assets, and run the application in release mode:
1npm run build2cargo run --release1npm run build2cargo run --release
If you use Inertia server-side rendering, set INERTIA_SSR=true and build with npm run build:ssr instead. Then run node bootstrap/ssr/app.js alongside your application.
When you're ready to put your application on a server, the deployment guide walks you through building, configuring, and running it in production.
Before you deploy, check that APP_ENV is production and APP_DEBUG is false. With debug mode on, server errors render a page with the error, its causes, the route, and the request, for anyone to see.
Health checks
Load balancers and uptime monitors often need a way to tell whether your application is running. Your application answers these health checks at /up, which responds with a 200 once your application has started. The route is registered in src/app.rs, where you may change its path:
1.with_routing(|routing, _| {2 routing3 .web(routes::web::routes)4 .api(routes::api::routes)5 .health("/up");6})1.with_routing(|routing, _| {2 routing3 .web(routes::web::routes)4 .api(routes::api::routes)5 .health("/up");6})
Point your load balancer or monitoring service at this URL. The routing guide covers what the health route checks.
Deploying to Laravel Cloud
When you're ready to put your Laravel Rust application in front of real users, Laravel Cloud is the best place to run it. Laravel Cloud is a fully managed deployment platform from the team behind Laravel. It deploys your application each time you push to Git and includes:
- Autoscaling that follows your traffic, and scale-to-zero when your application is idle, so you only pay for what you use
- Preview environments for every pull request
- Managed MySQL and Postgres databases, and Valkey caches
- Managed queues whose workers scale with the jobs waiting
- Object storage for your application's files
- Managed WebSocket servers
To deploy your application, get started with Laravel Cloud.
Next steps
Now that your application is running, you may be wondering what to learn next. Start with these guides to see how a Laravel application fits together:
Once you're comfortable with the basics, you're ready to start building. These guides walk you through the pieces most applications use first, from defining routes and validating input to storing data and testing your work: