Laravel Rust vs. Laravel PHP: Code, Performance, and Migration Trade-offs

Compare Laravel Rust and Laravel PHP through the same API endpoint, Eloquent and typed queries, queues, deployment, and Laravel’s benchmark. Learn when to use Octane, stay on PHP, or move one workload to Rust.
A Laravel team looking at Rust usually has one of two questions. Can we serve more traffic with the same infrastructure? Or can we make a new service easier to change without breaking its contracts? Both are worth testing. The best answer for a mature PHP application may be to keep its product logic in PHP and move a narrowly defined workload once measurements support the change.
Laravel Rust entered public beta on December 1, 2026. It brings Laravel conventions to a compiled Rust web framework built on Axum and Tokio. Laravel PHP remains the mature PHP framework with Eloquent, Composer packages, and established production tooling. The two share ideas about routing, models, and jobs. They have separate implementations and dependency ecosystems. This comparison uses Laravel PHP 13.x and the Laravel Rust public beta. Laravel Rust announcement · Laravel PHP documentation
What actually changes?
| Dimension | Laravel PHP | Laravel Rust |
|---|---|---|
| HTTP execution | PHP-FPM is a common deployment, with a PHP worker serving a request. Octane keeps the application booted across requests. | The executable runs an async HTTP server. Tokio schedules concurrent I/O across its runtime threads. |
| Request validation | A Form Request validates incoming values at runtime and provides validated data via validated() or safe(). |
An input struct carries field types, validators, and an explicit authorization rule. A typed extractor hands the handler validated input. |
| Models | Eloquent uses attributes, casts, relationships, scopes, and observers. | Models and supported query expressions use Rust types. Relationships are loaded explicitly. |
| Dependencies | Composer packages, PHP extensions, and the established Laravel ecosystem. | Cargo crates and Laravel Rust integrations. An equivalent application capability may need a different library or design. |
| Async work | Queued jobs, chains, batches, and a wide range of existing monitoring and deployment patterns. | Async queue workers and durable workflows that can persist progress across worker restarts. |
| Build and release | Composer install, PHP runtime and extensions, an asset build when applicable, and worker reloads. | A target-specific release build, runtime configuration, assets when needed, and independently managed web and worker processes. |
The Rust compiler checks types and ownership before the executable runs. It can catch passing a string to a typed query that expects a numeric ID. If the actual production schema is behind the model, a correctly typed query can still fail. Both stacks need migration tests, data constraints, and authorization tests. PHP teams can narrow part of the type-checking gap with DTOs, enums, and PHPStan or Larastan. Laravel Rust models · Eloquent documentation
The same API endpoint in PHP and Rust
Consider a ticket preview endpoint. POST /api/tickets/preview accepts JSON with a required subject of up to 120 characters. It returns 200 with the subject on a successful request. For JSON requests, an empty subject should produce a 422 validation response. This example has no storage or side effects, so the route can be public. A real ticket creation endpoint would authenticate the caller and authorize access to the workspace.
Laravel PHP uses a Form Request
In app/Http/Requests/PreviewTicketRequest.php, put the input rules and the authorization decision in the request class.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class PreviewTicketRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'subject' => ['required', 'string', 'max:120'],
];
}
}
Register the handler in routes/api.php. For a fresh app without API routing, enable it in the PHP application's bootstrap. Keep the normal /api prefix.
<?php
use App\Http\Requests\PreviewTicketRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Route;
Route::post('/tickets/preview', function (
PreviewTicketRequest $request
): JsonResponse {
return response()->json([
'subject' => $request->validated('subject'),
]);
});
Laravel resolves and validates the Form Request before calling the route handler. An application with additional domain logic can turn the validated array into a typed command or DTO before calling a service. PHP Form Request validation
Laravel Rust uses a typed input extractor
In a Rust app with src/routes/api.rs registered as its API route module, put these definitions in that file or move the handler to a dedicated module. Merge the registration into the existing routes function if the file already has one.
use laravel::prelude::*;
use serde_json::{Value, json};
#[laravel::input]
#[validate(anyone)]
pub struct PreviewTicket {
#[validate(required, max_length(120))]
pub subject: String,
}
pub fn routes(route: &mut Router) {
route.post("/tickets/preview", preview_ticket);
}
async fn preview_ticket(Valid(input): Valid<PreviewTicket>) -> Json<Value> {
Json(json!({ "subject": input.subject }))
}
Here the handler receives a validated PreviewTicket and can access input.subject as a String. The application's permission decision still belongs in authorization logic. #[validate(authenticated)] is enough for an action open to any signed-in user. Access to a tenant-owned ticket needs a policy or equivalent ownership check as well. Rust validation · Rust JSON responses
Run this request against each application, substituting its port. A second request with {"subject":""} should return 422 on both.
curl -i http://127.0.0.1:8000/api/tickets/preview \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"subject":"Cannot export attendance"}'
When moving an existing API, write shared contract cases for missing fields, null, whitespace, the maximum length, malformed JSON, and non-string values. Compare both HTTP status and error body. Matching rule names alone gives clients no guarantee that normalization, error keys, or error messages are identical.
Eloquent versus typed queries
A Laravel PHP application can eager-load an author relationship by name. Assuming a model with the same relationship exists, Laravel Rust expresses that relationship as an associated item. Both examples fetch the post with ID 42 or use the framework's not-found error path.
$post = Post::query()
->with('author')
->findOrFail(42);
let post = Post::query()
.with(Post::author)
.find_or_fail(42)
.await?;
In Eloquent, reading an unloaded relationship may issue another query. That is helpful while exploring a model and can turn a list of 100 records into many queries if you access the relation inside a loop. PHP can enable Model::preventLazyLoading() to surface that mistake. Rust's model layer expects relationship data to be loaded explicitly. Either approach still needs query plans, bounded pagination, and indexes on the columns your workload filters by. Eloquent relationships · Rust model relationships
The larger migration issue is hidden persistence behavior. Inventory observers that send notifications, global scopes that enforce tenancy, soft deletes, model casts that handle money or timestamps, and listeners that publish events. Build parity tests around the outcomes. For example, a model observer that adjusts an account balance may depend on whether writes pass through a model instance or update rows in bulk. Two services can use the same database schema and still behave differently.
For concurrent writes, PostgreSQL is the arbiter. If 500 students submit work at the same time and the requests serialize behind the same locked row, replacing PHP request workers with Tokio leaves the lock queue in place. Database-level changes such as reducing time inside the transaction, isolating writes per attempt, and enforcing unique submission keys are the things to measure first. Moving a read-only result endpoint or an export worker gives the new runtime a cleaner pilot.
Queues, authentication, and existing packages
Queues. Laravel PHP gives teams jobs, chains, batches, retry policies, and familiar tools such as Horizon for Redis queues. Laravel Rust provides its own jobs and a durable workflow abstraction for multi-step processes that need to resume across worker restarts. Introduce a versioned JSON payload or an HTTP contract when PHP and Rust exchange work. Include an ID, a schema version, and enough context for the consumer to handle a retry. Let each side keep its own internal job representation. PHP queues · PHP Horizon · Rust workflows
Authentication. A PHP app using Passport may already own OAuth2 client registrations, tokens, scopes, and revocation. For a pilot, keep token issuance with the existing system and give Rust an explicit identity contract, such as a service identity issued by an authentication gateway. Document how user identity and tenant permissions reach the worker or API, and how they expire. Plan session or token migration separately if the new service needs to own sign-in. Laravel Passport · Rust authentication
Packages. List the dependencies that would block your release. For a SaaS product, they may include billing, administration, permissions, localization, and partner SDKs. Record the exact behavior used, the team responsible for its replacement, and how much integration testing it requires. Package availability rarely matters for a read-only endpoint behind an existing gateway. It can dominate the schedule for a subscription application with invoices, payment updates, and refunds already working in PHP.
How to read Laravel's 18× throughput result
Laravel's published benchmark used two read endpoints on Laravel Cloud, a paginated feed and a single-record fetch. Its 20-minute traffic ramp ran against a small MySQL dataset of 200 records and 10 authors. The results below come from the vendor's published test and represent different measurements. Benchmark methodology and results · Benchmark applications and k6 configuration
| Reported measure | Laravel Rust | Laravel PHP |
|---|---|---|
| Highest successful throughput in a qualifying 10-second ramp window | 1,774 RPS | 97 RPS |
| p95 latency at a steady 50 RPS | 93 ms | 111 ms |
| p99 latency at a steady 50 RPS | 117 ms | 127 ms |
| Peak recorded memory at a steady 50 RPS | 16 MB | 134 MB |
| Median cold build on Laravel Cloud | 3 min 1 sec | 27 sec |
At their respective peaks, the implementations handled different amounts of traffic. The steady 50 RPS run compares them at the same offered load. At that load, the p95 difference was 18 ms. The memory difference could matter more when sizing replicas. The cold-build difference can matter to a team that deploys frequently. The throughput headline tells you how those two configurations handled the ramp.
If the current baseline is Laravel PHP behind PHP-FPM and traces show substantial application bootstrap or worker overhead, add Laravel Octane to the evaluation. It keeps the application booted within a worker, so benchmark it with the same business code, database pool limits, and CPU and memory allocation. Review dependencies for long-lived worker behavior, especially anything that caches the current request or user in a singleton. Laravel Octane
A fair benchmark for your application
- Freeze the workload. Use the same anonymized data shape, endpoint mix, user distribution, cache warmup, and upstream service behavior across variants.
- Compare deployable configurations. Test your current PHP runtime, the PHP configuration you can realistically ship, and the Rust pilot. Record each worker count, pool limit, and instance size. Include the queue workers if they serve the same feature.
- Choose a service-level target. For example, hold p95 below 200 ms and errors below 0.1% for a 15-minute test. Identify the highest sustained rate each configuration meets under that target.
- Measure the bottleneck. Record CPU, memory, database query and lock time, pool wait, and old messages in the queue. A request that waits on storage or a provider call has a different optimization path from one that spends most of its time in your process.
- Repeat and test failure. Use multiple runs. Inject a slow upstream or paused broker and check timeouts, retry behavior, and how quickly the queue recovers.
A simple cost model includes both runtime and engineering cost. If a Rust pilot saves $400 per month in infrastructure and takes $12,000 to implement and operate through the initial cutover, the infrastructure-only payback is 30 months before any ongoing change in on-call or maintenance costs. These are illustrative numbers. The same project may still be worthwhile if it sustains a traffic spike that the existing deployment cannot serve.
What to keep in PHP and where a Rust pilot fits
| Your situation | First move |
|---|---|
| A package-heavy SaaS has predictable traffic and meets its targets | Keep the application on PHP. Prioritize product work and monitor its capacity. |
| PHP application bootstrap consumes substantial time or CPU | Benchmark Octane with the current product code and review long-lived worker behavior. |
| A slow API is mostly waiting on SQL or locks | Address the query, connection pool, or transaction design and measure it again. |
| CPU-heavy processing or a read-heavy service has a clear interface | Build a small Rust pilot and use a workload-specific benchmark. For CPU-bound work, bound worker concurrency independently of the HTTP runtime. |
| A new app has a Rust-capable team and few package dependencies | Evaluate Laravel Rust in staging and budget for beta API changes and toolchain support. |
| Billing, sessions, and several PHP packages would need to move together | Keep the existing owners. Extract a smaller service with its own cutover and rollback path. |
For an existing product, start by exposing the same contract through a gateway. Run the Rust implementation against staging fixtures and compare status, schema, pagination, and auth decisions with PHP. Mirror only requests that can safely run twice. Use a single authoritative writer for shared data, and choose one owner for schema migrations. When you send real traffic to the pilot, start with a bounded segment and keep the existing route ready for rollback. Confirm that rollback remains possible after any schema change.
Before promoting the pilot, require an improvement large enough to justify two runtimes in production. Record the agreed p95 and error targets, the cost per unit of traffic, and the commands the on-call team needs to diagnose a failed deploy. For most PHP teams, the first production question is which component benefits from Rust. The answer comes from traces, contract tests, and day-to-day ownership.
Build your first Laravel Rust API on GAUAB · Compare Laravel Go and Laravel Rust on GAUAB
Featured Articles
Build a Task CRUD API in Laravel Rust and Laravel PHP with PostgreSQL
Build the same PostgreSQL-backed task API in Laravel PHP and Laravel Rust. Get complete code for all five CRUD endpoints, a shared smoke test, and a side-by-side comparison of the two implementations.

Laravel Rust in Practice: Build an API, Validate Requests, and Deploy It
Build your first API with the Laravel Rust beta. Learn typed validation, PostgreSQL models, async queues and workflows, and how to measure whether a Rust pilot is worth shipping.

Laravel Go vs. Laravel Rust: An Engineering Guide for PHP Teams
A hands-on comparison of Laravel Go, Laravel Rust, and PHP, with route examples, benchmark analysis, and a production migration plan.
Comments
0 commentsNo approved comments are visible yet. New community replies may wait for moderation.