← All guides

Published · 5 min read

Laravel Rust vs Laravel PHP: what changes, and when to switch

What stays the same, what's different day to day, what Laravel's own benchmark measured, and when moving from Laravel PHP to Laravel Rust is worth it.

  • comparison
  • php
  • getting-started
On this page
  1. What stays the same
  2. What changes day to day
  3. What Laravel’s benchmark measured
  4. When switching is worth it
  5. Quick reference

Laravel describes Laravel Rust as Laravel “reimagined in idiomatic Rust”: the same conventions and built-in features, rebuilt around a compiler rather than ported line by line. If you’ve used Laravel PHP for years, most of it will feel familiar within a day. Most of what’s new is work the compiler now does for you.

From saving a file to serving a request. In Laravel PHP you save, refresh and the request runs, so a misspelled column or route name fails at runtime. In Laravel Rust, saving starts a compile on your machine that checks column names and their types, links to routes, who may submit every form, and that nothing is lazy loaded; then one binary, with the migrations inside, serves the request. Routes, handlers, middleware, validation, models, queues, the scheduler, mail, Inertia and .env files stay the same.

What stays the same

  • The shape of an app. Routes in a web file and an api file, handlers grouped by resource (they do the job of controller methods), middleware, sessions, CSRF protection, .env files and an APP_KEY.
  • The features. Validation, an ORM with relationships and eager loading, migrations, seeders and factories, queues, the scheduler, mail, notifications, broadcasting, cache, file storage, authentication and authorization. Laravel calls it “near feature parity” with Laravel PHP.
  • The frontend. Inertia with React, Vue or Svelte, including deferred props, polling, prefetching and server-side rendering. Or server-rendered views, if you prefer.
  • The command line. laravel migrate, laravel route:list, laravel dev. The laravel command does the job of php artisan.
  • Laravel Cloud. It detects a Laravel Rust app and runs it, with managed queues and scale to zero.

What changes day to day

There’s a compile step

PHP runs your files as they are. Rust compiles the whole app into one binary first, with your migrations inside it. laravel dev rebuilds and restarts on save, so the loop is still “save, refresh”, just slower. You get something for the wait: mistakes that PHP reports at runtime, or never, stop the build.

More is checked before your code runs

A few things the compiler catches that Laravel PHP doesn’t:

  • Column names in queries, and the types you compare them with.
  • Links to routes. You build them from the handler function (route!(orders::show, order.id)), not a route name string, so renaming a handler breaks the build instead of a link.
  • Forgotten authorization. Every validated input struct must declare who may submit it, or it doesn’t compile.
  • Lazy loading. Relationships are never loaded behind your back. You load what a page needs with with, so an N+1 query can’t creep in.

Mass assignment is part of the type

In Laravel PHP you guard a model with $fillable, and the form request lists rules separately:

class Payout extends Model
{
    protected $fillable = ['account_holder', 'iban', 'amount'];
}

In Laravel Rust the validated input struct is also the list of columns a request may write:

#[laravel::input(fills = Payout)]
#[validate(authenticated)]
pub struct StorePayout {
    #[validate(required, max_length(140))]
    account_holder: String,
    #[validate(required, max_length(34))]
    iban: String,
    #[validate(required, min_value(1))]
    amount_cents: u32,
}

A client that adds status=paid to the request changes nothing, because the struct has no status field to fill.

Everything is async

Laravel Rust runs on Axum and Tokio. Database queries, HTTP calls, Redis, queues and S3 don’t block, so one slow third-party API call doesn’t hold up other requests. In handlers, that mostly means writing .await? after calls that do I/O.

Deploys ship a binary

Instead of copying PHP files and running Composer on the server, you build once (cargo build --release) and run the binary, next to public/, resources/views/ and storage/. There’s no PHP-FPM, OPcache or web server process to configure: the binary is the server.

What Laravel’s benchmark measured

Laravel published a benchmark that ran the same small API (a list of posts and a single post, backed by MySQL) in six frameworks on identical Laravel Cloud instances. The figures below are Laravel’s, from their posts:

Measure Laravel Rust Laravel PHP
Best 10-second window without failures 1,774 requests/s 97 requests/s
CPU at a steady 50 requests/s about 4% about 52%
Median wake from scale-to-zero 154 ms 712 ms
Median cold build on Cloud about 3 minutes 27 seconds

Two caveats come from the benchmark post itself: the test apps were intentionally simple, and results for more complex apps will differ. Read the full post for the method, the latency figures and the other frameworks tested.

When switching is worth it

Start a new app in Laravel Rust when:

  • the app will handle a lot of traffic or long-lived connections, and the server bill or tail latency matters;
  • you want the compiler to catch as much as possible, especially if coding agents write a lot of your code (Laravel built it with that in mind, and every new app ships with agent skills);
  • you’re happy to learn Rust, or already know it.

Stay on Laravel PHP when:

  • you have a working PHP app. Laravel has said plainly that Laravel PHP is not going into maintenance mode, and weekly releases continue. A rewrite needs a better reason than a benchmark;
  • you depend on packages from the PHP ecosystem that have no Rust equivalent yet;
  • you need a framework that’s already called stable. Laravel Rust is a beta; Laravel plans to call it stable after about six to eight weeks of feedback.

You can also split the difference: build the next new piece, such as a webhook receiver, an internal tool or a high-traffic API, in Laravel Rust, and keep the main app on PHP. Laravel Cloud runs both.

Quick reference

Laravel PHP Laravel Rust
php artisan … laravel …
Controller method Handler function in src/http/handlers/
FormRequest class #[laravel::input] struct with #[validate(...)]
$fillable The fields of a fill struct
route('orders.show', $id) route!(orders::show, id)?
Lazy loading Not available: eager load with with
PHP-FPM behind a web server One binary that serves HTTP itself