Skip to content
Back to skills

Laravel Php To Rust

ASecurity

Port a Laravel PHP (Laravel 13) application, or Laravel PHP habits, to Laravel for Rust (the laravel-rust crate). Use when moving routes, controllers, form requests, Eloquent models, migrations, policies, Sanctum, jobs, events, the scheduler, mail, Blade, Inertia pages or Pest tests from PHP to Rust, or when a Laravel PHP developer writes Laravel for Rust code and reaches for facades, route names, $fillable, lazy loading, soft deletes, down() migrations or Carbon formats. Maps each concept to...

  • 24 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added December 3, 2026
devopsrustgophpreactgitapidatabasedocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 18 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill laravel-php-to-rust --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Laravel Php To Rust?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Laravel Php To Rust
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-laravel-php-to-rust/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-laravel-php-to-rust)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel-php-to-rust
description: "Port a Laravel PHP (Laravel 13) application, or Laravel PHP habits, to Laravel for Rust (the laravel-rust crate). Use when moving routes, controllers, form requests, Eloquent models, migrations, policies, Sanctum, jobs, events, the scheduler, mail, Blade, Inertia pages or Pest tests from PHP to Rust, or when a Laravel PHP developer writes Laravel for Rust code and reaches for facades, route names, $fillable, lazy loading, soft deletes, down() migrations or Carbon formats. Maps each concept to its Rust equivalent, lists the PHP features with no equivalent and what replaces them, and flags the behaviour that differs. Every Rust example compiles against laravel-rust 0.2.0, and the main differences were tested on that version. Not for auditing an existing Rust app (use laravel-rust-audit)."
license: MIT
metadata:
  author: AsyrafHussin
  version: "1.1.0"
  laravelRustVersion: "0.2.x (tested 0.2.0)"
  laravelPhpVersion: "13.x"
  rustVersion: "1.99+"
---

# Laravel PHP to Laravel for Rust

Port a Laravel PHP application, or the habits of a Laravel PHP developer, to [Laravel for Rust](https://laravel.com/rust). Contains 28 rules across 9 categories. Every Rust example compiles against `laravel-rust` 0.2.0, and each "Tested" note records what a test or command run on that version showed.

**Version 1.1.0 (December 2026).** Laravel for Rust is in beta, and releases before 1.0 may change APIs. The bundled docs never mention PHP, so there is no official porting guide; check every API against the docs bundled with the version you install. To move an app to a newer release, use the `upgrading-laravel-rust` skill that new apps ship in `.agents/skills/`.

## When to Apply

- Porting a Laravel PHP app, or one feature of it, to Laravel for Rust
- A Laravel PHP developer starting a Laravel for Rust app
- Reviewing Rust code that looks like PHP: facades, route names, `$fillable`, `save()`, `down()`, `Inertia::lazy`, `'Y-m-d'`

Not for: auditing a Laravel for Rust app (`laravel-rust-audit`), or writing new features without a PHP original (the app's own `.agents/skills/`, and `laravel-rust-best-practices`).

## How to Port

1. Start from `laravel new example-app --rust`, and read the bundled docs for the installed version (`port-plan`)
2. Inventory the PHP app, and decide each gap with `port-missing-features`
3. Port in layers: migrations and models, policies, routes with handlers and input structs, background work, mail and views
4. Port each feature's PHP tests with it, and run `cargo test`, `cargo clippy --all-targets`, `npm run types:check` and `npm run check`

## Quick Map

| Laravel PHP | Laravel for Rust | Rule |
|---|---|---|
| `Route::resource`, controllers | `resource!(posts)` over a module of handler functions | `http-routes-and-handlers` |
| `route('posts.show', $post)` | `route!(posts::show, &post)?` | `http-routes-and-handlers` |
| `FormRequest` | `#[laravel::input]` with `#[validate(..)]`; authorization required | `http-form-requests` |
| `max:255`, `in:a,b`, `nullable`, `sometimes` | `max_length(255)`, `one_of("a", "b")`, `Option<T>`, `Sometimes<T>` | `http-form-requests` |
| `$request->input('x')` | A typed struct: `Valid<T>` (body, last argument), `Query<T>` | `http-handler-arguments` |
| `abort(404)`, `response()->json($x, 201)` | `laravel::abort!(404)`, `Created(x)` | `http-responses-errors` |
| Middleware class + alias | `#[middleware] async fn`, referenced by name | `http-middleware-session` |
| Eloquent model, casts, `$hidden` | `#[model] struct`, typed fields, `#[serde(skip)]` | `data-models` |
| `$fillable`, `create()`, `update()`, `save()` | Fill struct, `create!`, `update!`; `Sometimes<T>` for PATCH | `data-writes` |
| `where`, `orWhere`, scopes | `.filter(a \| b)`, scope functions returning `db::Condition` | `data-queries` |
| Lazy loading, `->pivot`, `withCount` | `.with(..)` or a panic, `.join`, `.count()` | `data-relationships` |
| `up()` / `down()`, `migrate:rollback` | Forward-only `migrate` functions | `data-migrations` |
| Factories, seeders | `#[factory(Post)]` structs, `#[seeder]` functions | `data-factories-seeders` |
| `SoftDeletes`, global scopes, observers | `deleted_at` + scope, explicit scopes, model event listeners | `data-soft-deletes-scopes-observers` |
| `Auth::attempt`, guards | `Auth<User>`, one session guard, `#[laravel::auth::page(..)]` | `auth-guards-and-login` |
| Sanctum | A `RequestGuard` over hashed tokens | `auth-api-tokens` |
| `Gate`, policies, `@can` | `#[policy]` methods passed by name; booleans to the view | `auth-policies` |
| `Password::sendResetLink`, `Hash::make`, `MustVerifyEmail` | `Passwords<User>`, automatic hashing, the derive plus marked pages | `auth-passwords-verification` |
| `config()`, `env()`, `app()`, facades | `Section<T>`, `#[env(..)]`, `Inject<T>`, module functions | `app-config-env-container` |
| `Cache`, `Storage`, `Http::..->throw()` | `cache::`, `storage::`, `client::..ensure_successful()` | `app-cache-storage-http` |
| Artisan commands, `Log`, Carbon | `#[command]` functions, `tracing`, `laravel::now()` in UTC with strftime | `app-console-logging-time` |
| `ShouldQueue` jobs, Horizon | `#[derive(Queueable)]` + `#[job]`, `queue:work` | `async-jobs-and-queues` |
| Events, listeners, `Schedule` | `#[listener]` functions, `#[schedule::tasks]` in UTC | `async-events-and-scheduling` |
| Mailables, notifications, Echo | `#[derive(Mailable)]`, `#[notification]`, `namespace: false` | `async-mail-notifications-broadcasting` |
| Blade | MiniJinja templates | `view-blade-to-templates` |
| `Inertia::render`, `Inertia::optional` (older apps: `Inertia::lazy`) | `inertia::render`, `inertia::optional`; not `inertia::lazy` | `view-inertia` |
| Pest, `actingAs`, fakes | `#[laravel::test]`, `.acting_as(&user)` on the request, bound fakes | `test-pest-to-laravel-test` |
| `artisan optimize`, `storage:link` | A release binary with `public/`, `resources/views/`, `storage/` | `deploy-release-binary` |

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Porting Method | CRITICAL | `port-` |
| 2 | Data | CRITICAL | `data-` |
| 3 | HTTP | HIGH | `http-` |
| 4 | Authentication and Authorization | HIGH | `auth-` |
| 5 | Application Services | HIGH | `app-` |
| 6 | Background Work | HIGH | `async-` |
| 7 | Tests | HIGH | `test-` |
| 8 | Deployment | HIGH | `deploy-` |
| 9 | Views | MEDIUM | `view-` |

## Quick Reference

### 1. Porting Method (CRITICAL)

- `port-plan` - Start from a new app, read the bundled docs, port in layers with the PHP tests
- `port-missing-features` - The PHP features with no equivalent, and what replaces each

### 2. Data (CRITICAL)

- `data-models` - Typed fields, `Option` for nullable columns, `#[serde(skip)]`, response structs
- `data-writes` - Fill structs, `create!`, `update!`; `Option` clears columns on PATCH, `Sometimes` keeps them
- `data-queries` - Typed filters; `|` inside one `filter` for or; scope functions
- `data-relationships` - No lazy loading; `tags().delete()` deletes tags, `detach` unlinks
- `data-migrations` - Forward-only, directly in `database/migrations`
- `data-factories-seeders` - States before `count`; seeders are functions
- `data-soft-deletes-scopes-observers` - Soft deletes, global scopes and observers, ported explicitly

### 3. HTTP (HIGH)

- `http-routes-and-handlers` - Handler modules, `resource!`, linking by handler
- `http-form-requests` - Input structs, renamed rules, required authorization, `Sometimes`
- `http-handler-arguments` - Typed extractors, body last, lenient query structs
- `http-responses-errors` - `abort!` returns, `abort()` does not; `Created`; flash for Inertia
- `http-middleware-session` - Function middleware; global middleware cannot see the user

### 4. Authentication and Authorization (HIGH)

- `auth-guards-and-login` - `attempt` returns an error, not `false`; one guard; marked pages
- `auth-api-tokens` - Sanctum becomes a request guard over hashed tokens
- `auth-policies` - `Gate::define` becomes a policy; no `@can`; authorize the route
- `auth-passwords-verification` - Queued resets, automatic hashing, `MustVerifyEmail` derive

### 5. Application Services (HIGH)

- `app-config-env-container` - Typed sections read at start-up; no runtime `env()`
- `app-cache-storage-http` - `ensure_successful`; `memory` cache is per process; locks need releasing
- `app-console-logging-time` - `#[command]`, `tracing`, UTC, `%Y-%m-%d`

### 6. Background Work (HIGH)

- `async-jobs-and-queues` - Missing models drop jobs, renames orphan them, no Horizon or `ShouldBeUnique`
- `async-events-and-scheduling` - The schedule runs in UTC; a failing listener stops the rest
- `async-mail-notifications-broadcasting` - No SMTP; the `log` mailer is the default; Echo `namespace: false`

### 7. Tests (HIGH)

- `test-pest-to-laravel-test` - Pest and PHPUnit assertions mapped; `queue::fake();` as a statement fakes nothing; `acting_as` skips the session

### 8. Deployment (HIGH)

- `deploy-release-binary` - `SERVER_HOST=0.0.0.0`, ship views and assets, restart workers

### 9. Views (MEDIUM)

- `view-blade-to-templates` - MiniJinja; `{{ csrf_field() }}`, not `@csrf`
- `view-inertia` - `inertia::lazy` is not PHP's `Inertia::lazy`; use `optional`

## How to Use

Read individual rule files for the PHP original, the differences, and the incorrect and correct Rust:

```
rules/port-plan.md
rules/data-writes.md
rules/http-form-requests.md
```

Each porting rule contains:
- The Laravel PHP code being ported
- What changes, with quotes from the bundled docs
- Incorrect Rust that follows the PHP habit, and, where it was run, what it did on 0.2.0 (a "Tested" note)
- Correct Rust
- References to the bundled guides

The two porting-method rules (`port-plan`, `port-missing-features`) have Why It Matters, steps or a table of gaps, and Incorrect and Correct examples instead.

## References

- [Laravel for Rust](https://laravel.com/rust)
- [Laravel for Rust documentation](https://laravel.com/rust/docs)
- [laravel/rust skeleton](https://github.com/laravel/rust)
- [laravel/laravel-rust-flux-react starter](https://github.com/laravel/laravel-rust-flux-react) (login, registration and password reset)
- [Laravel 13 documentation](https://laravel.com/docs/13.x)

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

Files in this skill

  • README.md4.3 KB
  • SKILL.md10.1 KB
  • rules/_sections.md1.9 KB
  • rules/_template.md694 B
  • rules/app-cache-storage-http.md3.2 KB
  • rules/app-config-env-container.md3.3 KB
  • rules/app-console-logging-time.md2.8 KB
  • rules/async-events-and-scheduling.md3.8 KB
  • rules/async-jobs-and-queues.md5.5 KB
  • rules/async-mail-notifications-broadcasting.md3.5 KB
  • rules/auth-api-tokens.md3.9 KB
  • rules/auth-guards-and-login.md6.2 KB
  • rules/auth-passwords-verification.md6.4 KB
  • rules/auth-policies.md3.6 KB
  • rules/data-factories-seeders.md3.3 KB
  • rules/data-migrations.md3.4 KB
  • rules/data-models.md4 KB
  • rules/data-queries.md4.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in devops →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.