Laravel Php To Go
ASecurityPort a Laravel PHP (Laravel 13) application, or Laravel PHP habits, to Laravel for Go (the go.laravel.com module). 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 Go, or when a Laravel PHP developer writes Laravel for Go code and reaches for $fillable, save(), lazy loading, soft deletes, down() migrations, listener discovery, now() or Carbon formats. Maps each ...
- 24 stars
- 0 votes
- 0 copies
- 8 views
- Added December 4, 2026
Works with
Security analysis
100/100Pro scans all 18 files and shows the line behind each finding
npx -y skills add gabrielmoreira/agent-skills-mirror --skill laravel-php-to-go --agent claude-codeAre you the author of Laravel Php To Go?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-laravel-php-to-go)---
name: laravel-php-to-go
description: "Port a Laravel PHP (Laravel 13) application, or Laravel PHP habits, to Laravel for Go (the go.laravel.com module). 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 Go, or when a Laravel PHP developer writes Laravel for Go code and reaches for $fillable, save(), lazy loading, soft deletes, down() migrations, listener discovery, now() or Carbon formats. Maps each concept to its Go equivalent, lists the PHP features with no equivalent and what replaces them, and shows the PHP habit that compiles in Go but behaves differently. Every Go example compiles against go.laravel.com v0.2.0, and the main differences were tested on that version. Not for code with no PHP original (use laravel-go-best-practices) or tests alone (use laravel-go-testing)."
license: MIT
metadata:
author: AsyrafHussin
version: "1.1.0"
laravelGoVersion: "0.2.x (tested 0.2.0)"
laravelPhpVersion: "13.x"
goVersion: "1.27+"
---
# Laravel PHP to Laravel for Go
Port a Laravel PHP application, or the habits of a Laravel PHP developer, to [Laravel for Go](https://laravel.com/go). Contains 32 rules across 9 categories. Every Go example compiles against `go.laravel.com` v0.2.0 and is a file of a test app, and each "Tested" note records what a test on that version asserted.
**Version 1.1.0 (December 2026).** Laravel for Go is in beta, and releases before 1.0 may change APIs. The bundled docs are not a porting guide; check every API against the docs bundled with the version you install (`.agents/skills/writing-laravel-go-apps/scripts/docs-path.sh` prints their path). To move an app to a newer release, use the `upgrading-laravel-go` skill a new app ships in `.agents/skills/`; it applies the breaking changes in the release's `docs/upgrade.md`.
## When to Apply
- Porting a Laravel PHP app, or one feature of it, to Laravel for Go
- A Laravel PHP developer starting a Laravel for Go app
- Reviewing Go code that looks like PHP: `model.Save` after setting fields, `r.FormValue`, `os.Getenv`, `time.Now()`, `"Y-m-d"`, an `auth.Authorize` result that is not returned
Not for: writing new features without a PHP original (`laravel-go-best-practices`, and the skills the app ships in `.agents/skills/`), or testing (`laravel-go-testing`).
## How to Port
1. Start from `laravel new example-app` (choose Go), 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. Point the Go app at the PHP database only after checking migration names, morph type names and password hashes (`data-migrations`, `data-polymorphic-types`, `auth-passwords-verification`)
4. Port in layers: models, policies, routes with handlers and form structs, background work, mail and views; list every job, listener, command and migration in its registry, because nothing is discovered
5. Port each feature's PHP tests with it, and run `go vet ./...` and `go test ./...`
## Quick Map
| Laravel PHP | Laravel for Go | Rule |
|---|---|---|
| Listener discovery, auto-loaded classes | `listeners.All`, `jobs.All`, `commands.All`, `migrations.All` | `port-plan` |
| Scout, Socialite, Pennant; Horizon, Telescope, Livewire | `search`, `auth/social`, `feature`; no equivalent | `port-missing-features` |
| Eloquent model, casts, accessors, `$hidden` | Plain struct, typed fields, response structs | `data-models` |
| `$fillable`, `$attributes` defaults | Form structs; `db:",default"` with a pointer field | `data-fillable-and-defaults` |
| `save()`, `update()`, `increment()` | `model.Create`, `model.Update`, `model.Increment` (`model.Save` writes every column but the key and `created_at`) | `data-writes` |
| `first()` returning null, `paginate()` | `*db.NotFoundError`, returned paginators | `data-queries-and-pagination` |
| Lazy loading, `withCount` | `With(...)` up front (nothing lazy-loads); a count field | `data-relationships` |
| `App\Models\Post` morph types | `MorphName` that returns the stored name | `data-polymorphic-types` |
| `SoftDeletes`, global scopes | `DeletedAt` and scopes you apply | `data-soft-deletes-and-scopes` |
| Observers | `Creating`/`Updating`/`Deleting` hooks to stop a write | `data-observers-to-hooks` |
| `DB::transaction` | `db.Transaction` with the callback's `ctx` everywhere | `data-transactions` |
| Migrations, `down()`, `migrate:rollback` | Same `migrations` table and names; forward-only | `data-migrations` |
| Factories, seeders, `WithoutModelEvents` | `factory.New`, named seeders with `WithoutEvents` | `data-factories-seeders` |
| `Route::resource`, `route()`, scoped bindings | Handler packages, `urls.Route` with names, `model.Related` | `http-routes-and-handlers` |
| `FormRequest` | Form struct with `Rules`, `Authorize` before binding | `http-form-requests` |
| `$request->input()` | `r.Validate[T]`, `r.Query[T]` | `http-input` |
| `abort(403)`, API Resources | `return web.Abort(403)`, response structs | `http-responses-errors` |
| Middleware classes, `session()->get()` | Middleware values, `r.Session().Value[T]` | `http-middleware-session` |
| `Auth::attempt`, `auth()->user()` | `auth.Attempt`, `r.User`, `auth.WithUser` outside requests | `auth-login-and-guards` |
| Sanctum | A request guard over the token table, with expiry and abilities | `auth-api-tokens` |
| Policies, `$this->authorize()` | Ability functions; return the denial | `auth-policies` |
| `Hash` (bcrypt), password change, verification | `hash`, `auth.UpdatePassword` | `auth-passwords-verification` |
| Blade | `html/template` views | `view-blade-to-templates` |
| `Inertia::lazy`, `Inertia::optional` | `inertia.Optional` (not `inertia.Lazy`) | `view-inertia` |
| `env()`, `config()`, the container | `services.New`, `config.From(ctx)`, `services.From(ctx)` | `app-config-env-services` |
| `Cache`, `Storage`, `Http`, `Process` | `cache`, `storage`, `http`, `process` with `ctx` | `app-cache-storage-http` |
| `now()`, `Log`, Artisan commands | `date.Now(ctx)`, `slog` with `ctx`, command types | `app-console-logging-time` |
| `ShouldQueue`, `SerializesModels`, `$tries` | Job structs with exported fields, `queue:"model"`, `JobOptions` | `async-jobs-and-queues` |
| Events, listeners, `Schedule` | Inside a transaction, listeners wait for the commit (not with `ListenAtDispatch`, or an event whose `AtDispatch()` returns true); schedule in UTC | `async-events-and-scheduling` |
| Mailables, `Mail::queue`, notifications | `mail.Message`, rendered when queued | `async-mail-notifications-broadcasting` |
| Pest, `actingAs`, fakes | `go test`, the client `ActingAs` returns, `laraveltest` fakes | `test-pest-to-go-test` |
| php-fpm, `artisan optimize`, `queue:work --tries` | One binary; tries on the job | `deploy-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, list every listener and job; an unlisted listener never runs
- `port-missing-features` - The PHP packages and commands with no equivalent, and the built-in replacements
### 2. Data (CRITICAL)
- `data-models` - Plain structs; accessors and `$appends` need a response struct; `GitHubID` maps to `git_hub_id`; Go date layouts
- `data-fillable-and-defaults` - Form structs instead of `$fillable`; `false` on a `db:",default"` field stores the default
- `data-writes` - `model.Save` writes every column except the primary key and `created_at`, and never inserts; use `model.Update` for changes and `model.Create` for new rows
- `data-queries-and-pagination` - `First` returns an error where PHP gave null; paginator methods return a new value
- `data-relationships` - Nothing lazy-loads: reading through an unloaded belongs-to or has-one panics, and an unloaded has-many is empty
- `data-polymorphic-types` - Rows the PHP app stored as `App\Models\Post` are invisible without `MorphName`
- `data-soft-deletes-and-scopes` - No soft deletes or global scopes; `model.Delete` deletes the row
- `data-observers-to-hooks` - A model event listener (registered with `Listen`) inside a transaction runs after the commit and cannot undo the write; use a hook (or `laravel.ListenAtDispatch`, whose error rolls the transaction back when the callback returns it)
- `data-transactions` - Pass the callback's `ctx` to every call; `r` inside `db.Transaction` runs outside it
- `data-migrations` - Keep the PHP migration names; forward-only; listed in `migrations.All`
- `data-factories-seeders` - Seeders fire model events unless they set `WithoutEvents`
### 3. HTTP (HIGH)
- `http-routes-and-handlers` - Nested records are not scoped; `urls.Route` takes names and values
- `http-form-requests` - `Authorize` runs before the body is bound
- `http-input` - `r.FormValue` misses JSON; the body and the query string are read apart
- `http-responses-errors` - `web.Abort` must be returned; `web.JSON(model)` has no `data` wrapper
- `http-middleware-session` - Middleware values; a session number reads back as `float64`
### 4. Authentication and Authorization (HIGH)
- `auth-login-and-guards` - One session guard; commands and jobs have no user
- `auth-api-tokens` - Sanctum tokens need a guard that reads `id|plaintext`, expiry and abilities
- `auth-policies` - An `auth.Authorize` result that is not returned authorizes nothing
- `auth-passwords-verification` - PHP bcrypt hashes work (Argon2 hashes do not); `auth.UpdatePassword` keeps the current device logged in
### 5. Application Services (HIGH)
- `app-config-env-services` - `os.Getenv` ignores test overrides; services are shared by every request
- `app-cache-storage-http` - The cache stores JSON, so hidden fields are dropped; processes run without a shell
- `app-console-logging-time` - `time.Now()` ignores the test clock; `slog` without `ctx` loses context
### 6. Background Work (HIGH)
- `async-jobs-and-queues` - Unexported job fields arrive empty; missing models delete the job
- `async-events-and-scheduling` - Inside a transaction, listeners wait for the commit (unless registered with `ListenAtDispatch`, or the event's `AtDispatch()` returns true); the schedule runs in UTC
- `async-mail-notifications-broadcasting` - Queued mail is rendered when queued
### 7. Tests (HIGH)
- `test-pest-to-go-test` - `ActingAs` returns a new client; as a statement it does nothing
### 8. Deployment (HIGH)
- `deploy-binary` - One binary; `optimize` and `queue:work --tries` do not exist
### 9. Views (MEDIUM)
- `view-blade-to-templates` - A nil pointer renders `<nil>`; a misspelled field is a `500`
- `view-inertia` - `inertia.Lazy` is sent on the first visit; `inertia.Optional` is PHP's lazy prop
## How to Use
Read individual rule files for the PHP original, the differences, and the incorrect and correct Go:
```
rules/port-plan.md
rules/data-writes.md
rules/http-form-requests.md
```
Each rule contains:
- The Laravel PHP code being ported
- What changes: a mapping table, the PHP features with no equivalent, and quotes from the bundled docs
- A "Tested" note with what a test on v0.2.0 asserted, and which claims rest on the docs only
- Incorrect Go that follows the PHP habit
- Correct Go
- References to the bundled guides
## Full Compiled Document
For the complete guide with all rules expanded: `AGENTS.md`
Files in this skill
- README.md
- SKILL.md
- rules/_sections.md
- rules/_template.md
- rules/app-cache-storage-http.md
- rules/app-config-env-services.md
- rules/app-console-logging-time.md
- rules/async-events-and-scheduling.md
- rules/async-jobs-and-queues.md
- rules/async-mail-notifications-broadcasting.md
- rules/auth-api-tokens.md
- rules/auth-login-and-guards.md
- rules/auth-passwords-verification.md
- rules/auth-policies.md
- rules/data-factories-seeders.md
- rules/data-fillable-and-defaults.md
- rules/data-migrations.md
- rules/data-models.md
Attribution
Related skills
View all in devops →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.