# Installation - [Meet Laravel](#meet-laravel) - [Creating an application](#creating-an-application) - [Installing the Laravel CLI](#installing-the-laravel-cli) - [Creating your application](#creating-your-application) - [Databases and migrations](#databases-and-migrations) - [Running the application](#running-the-application) - [Running in production](#running-in-production) - [Health checks](#health-checks) - [Deploying to Laravel Cloud](#deploying-to-laravel-cloud) - [Next steps](#next-steps) ## Meet Laravel > [!WARNING] > 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](https://docs.rs/axum) and [Tokio](https://tokio.rs), 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](https://rustup.rs), Rust's official installer: ```shell curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` On Windows, download the installer from [rustup.rs](https://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](https://nodejs.org/en/download), which offers graphical installers for macOS and Windows. Most machines already have Git. If yours doesn't, download it from the [Git website](https://git-scm.com/downloads). ### 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: ```shell curl -fsSL https://laravel.com/install.sh | sh ``` On Windows, run this command in PowerShell instead: ```powershell powershell -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](https://herd.laravel.com) 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: ```shell laravel --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`: ```shell laravel new example-app cd 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](inertia.md), React, TypeScript, Tailwind, and [Vite Plus](https://viteplus.dev/). 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](encryption.md#gracefully-rotating-encryption-keys). 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](configuration.md) covers `.env` and the config files in `src/config/`. > [!NOTE] > 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`: ```ini DB_CONNECTION=postgres DATABASE_URL=postgres://postgres@127.0.0.1/laravel ``` > [!NOTE] > If you don't have PostgreSQL installed locally yet, [DBngin](https://dbngin.com/) (macOS and Windows) and [Postgres.app](https://postgresapp.com/) (macOS) let you start a local PostgreSQL server in a few clicks. You may change these defaults to suit your database. The [database guide](database.md#configuration) covers these settings in detail. Then run your [migrations](migrations.md) from your application's directory to create the `users`, `sessions`, and queue tables: ```shell laravel 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: ```ini DB_CONNECTION=sqlite DATABASE_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](migrations.md) 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: ```shell laravel 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](routing.md#listing-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: ```shell laravel 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: ```shell npm run build cargo run --release ``` If you use Inertia [server-side rendering](https://inertiajs.com/docs/v3/advanced/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](deployment.md) walks you through building, configuring, and running it in production. > [!WARNING] > 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: ```rust .with_routing(|routing, _| { routing .web(routes::web::routes) .api(routes::api::routes) .health("/up"); }) ``` Point your load balancer or monitoring service at this URL. The [routing guide](routing.md#the-health-route) 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](https://laravel.com/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](https://laravel.com/cloud/docs/compute#autoscaling) that follows your traffic, and [scale-to-zero](https://laravel.com/cloud/docs/compute#scale-to-zero) when your application is idle, so you only pay for what you use - [Preview environments](https://laravel.com/cloud/docs/preview-environments) for every pull request - Managed [MySQL](https://laravel.com/cloud/docs/resources/databases/laravel-mysql) and [Postgres](https://laravel.com/cloud/docs/resources/databases/postgres) databases, and [Valkey](https://laravel.com/cloud/docs/resources/caches/valkey) caches - [Managed queues](https://laravel.com/cloud/docs/queues) whose workers scale with the jobs waiting - [Object storage](https://laravel.com/cloud/docs/resources/object-storage) for your application's files - Managed [WebSocket servers](https://laravel.com/cloud/docs/resources/websockets) To deploy your application, [get started with Laravel Cloud](https://laravel.com/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: - [Development](development.md) - [Configuration](configuration.md) - [Directory structure](structure.md) - [Request lifecycle](lifecycle.md) 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: - [Routing](routing.md) - [Validation](validation.md) - [Database](database.md) - [Models](models.md) - [Inertia](inertia.md) - [Testing](testing.md)