Between the end of November and the first days of December 2026 Laravel got official ports to Rust and Go, and I ported my Laravel Codice Fiscale package to both. The package parses, generates and validates the Italian codice fiscale, and its PHP version has a framework-agnostic core plus a Laravel layer: a validation rule, an Eloquent cast, a Faker provider and an Artisan command that downloads birthplace data from Italian government sources. The Rust port is two crates, codicefiscale and laravel-codicefiscale, in laravel-codicefiscale-rs. The Go port is two modules in laravel-codicefiscale-go.
This post is about the porting work: how each Laravel piece moved to the new frameworks, how I checked that the ports behave like PHP, and what went wrong. How the three versions perform is in the companion post, Laravel for Rust and Go, first look.
How the port was run
The code was written by Claude Code agents. Both ports followed the same steps:
- a grilling session, where the agent asked me every open design question with a recommended answer, and I accepted or changed it;
- a spec, opened as issue #1 in the new repository;
- tickets, one GitHub issue per vertical slice;
- a
/goalthat kept the session going until every ticket was closed, with each ticket meant to be implemented test-first by a fresh subagent.
My part was the decisions in the grilling sessions, the approval of each merge and release, and the steps that needed my accounts: publishing the crates to crates.io and configuring the services on Render. Each repository keeps the working agreements the agents follow in AGENTS.md, a glossary in CONTEXT.md and 16 architecture decision records in docs/adr.
The commit timestamps say how fast this went once the decisions were made. The first commit of the Rust port landed at 20:05 on 1 December, and the port was merged at 21:39, about 95 minutes later. The first commit of the Go port landed at 09:15 on 3 December, and the port was merged at 10:23, about 70 minutes later. The clock starts after the grilling session and the spec, and it leaves out the showcase apps, the releases and a round of test hardening, which filled the rest of those three days.
The Go port started from everything the Rust port had settled. Decision records 0001 to 0007, which cover the domain (no bundled birthplace data, the century resolver, how a birthplace code is judged), are identical in both repositories. The golden corpus that defines parity (more on it below) is the same two files, and the Go dataset format is byte-compatible with the Rust one. The second port only had to answer the Go questions.
Core and adapter
The PHP package is one Composer package with two namespaces: Robertogallea\CodiceFiscale for the domain and Robertogallea\CodiceFiscale\Laravel for the framework. Both ports make the split physical.
| PHP | Rust | Go | |
|---|---|---|---|
| Core | namespace in the package | crate codicefiscale |
module …/codicefiscale |
| Laravel layer | namespace in the package | crate laravel-codicefiscale |
module github.com/robertogallea/laravel-codicefiscale-go |
| Framework | Laravel 12 and 13 | laravel-rust 0.1.x |
go.laravel.com v0.1.x |
The reason is the age of the frameworks. Both were days old, and a framework release that breaks the adapter should not force a new version of the domain code. The cores have no framework dependency. The Rust core builds for wasm32-unknown-unknown and keeps its extras (sources, serde, fake) behind optional features. The Go core has no third-party dependency at all and builds with Go 1.23 for wasip1 and js/wasm, while the adapter needs Go 1.27, the framework's floor. Both cores take an explicit reference date wherever PHP reads the clock, and the adapters pass the framework clock's date.
The validation rule
In PHP, a rule that also checks the code against the other fields of the request is one fluent call:
1'fiscal_code' => [CodiceFiscaleRule::make()->matching(
2 firstName: 'first_name',
3 lastName: 'last_name',
4 birthDate: 'birth_date',
5)],
A rule in Laravel for Rust 0.1 returns one message per entry, and so does a rule in Laravel Go. Since PHP reports one message per mismatched field, both ports use one matching rule per sibling field:
1#[laravel::input]
2struct Registration {
3 #[validate(
4 required,
5 CodiceFiscaleRule::new(),
6 CodiceFiscaleMatchRule::first_name("nome"),
7 CodiceFiscaleMatchRule::last_name("cognome")
8 )]
9 codice_fiscale: String,
10 nome: Option<String>,
11 cognome: Option<String>,
12}
1_ = validation.For(&in,
2 rule.Field(&in.CodiceFiscale,
3 rule.Required,
4 laravelcf.CodiceFiscale(),
5 laravelcf.Matches(laravelcf.FirstName, "nome"),
6 laravelcf.Matches(laravelcf.LastName, "cognome")))
When a code fails several checks at once, the single message holds one sentence per failure, in the core's order. The Go rule also drops a sentence identical to the one before it.
The Faker provider and the Artisan command moved with fewer changes. fake()->codiceFiscale() becomes a free function over the framework's Faker in both ports (fake_codice_fiscale and laravelcf.FakeCodiceFiscale), drawing from the same ten fixed municipalities, so it works with no dataset. codice-fiscale:update-places keeps its name and PHP's download policy (three attempts, ISTAT pages of 200 rows) and loses --municipalities-only and --countries-only, because the ports build the dataset as one file. Both ports also add codice-fiscale:install-skill, which writes an agent skill into the app; PHP gets its skill through Laravel Boost.
The Eloquent cast
PHP's CodiceFiscaleCast turns a column into a CodiceFiscale value object. It throws when you assign an invalid value and reads an invalid stored value as null, so legacy rows never make a model unusable.
Laravel for Rust 0.1 has no custom casts: the Rust type of a model field decides how its column is read and written, through the framework's Decode and Value traits. The adapter can't implement those traits for the core's CodiceFiscale, because Rust's orphan rule forbids implementing a foreign trait for a foreign type, and the core can't depend on the framework. So the adapter defines its own column types that wrap the core value:
1#[model]
2pub struct Person {
3 pub id: i64,
4 pub fiscal_code: CodiceFiscaleColumn, // NOT NULL
5 pub legacy_code: LenientCodiceFiscaleColumn, // nullable
6}
The lenient read side needs a type of its own, LenientCodiceFiscaleColumn, because the framework decodes every Option<T> through T's decoder and fails the row when that fails.
Laravel Go models map fields through database/sql. Any type that implements sql.Scanner and driver.Valuer works as a model field, and the core can implement both with the standard library. The Go adapter adds no column type:
1type Person struct {
2 ID int64
3 Tax codicefiscale.CodiceFiscale // NOT NULL
4 Spouse *codicefiscale.CodiceFiscale // nullable
5 Legacy codicefiscale.Lenient // never fails a row
6}
Lenient is shaped like sql.NullString, a Valid flag plus the value. All three versions write the same normalized string, so PHP, Rust and Go apps can share one database. This is the place where the two ports differ most, and the one where Go needed the least code.
The birthplace dataset
The PHP package downloads four government sources (ANPR municipalities, ISTAT suppressed municipalities, MAECI countries, ISTAT historical countries) into a dedicated SQLite file, and queries it on every call. It manages that file with its own migration and connection, and never touches the app's database.
Laravel for Rust 0.1 runs package migrations only on the app's default connection, so that design could not move as it was. The Rust port keeps the whole dataset in memory, and the file on disk is only persistence: one JSON file whose format is defined and versioned by the core, with a header that records the format version, the download date of each source and the PHP version it is at parity with. The update command writes it to a temporary file and renames it. The rename is also the reload signal: a framework tick checks the file's modification time, length and inode, and swaps the new data in atomically, so a running server picks up fresh data without a restart.
The Go port took the same design and the same format. Its test dataset was built by a throwaway program that calls the Rust core, and Go's BuildDataset reproduces it byte for byte from the same source files. The Go source parsers use only the standard library, an XLSX reader for the MAECI file included.
Messages, locale and config
The PHP messages come in English and Italian through Laravel's translator. Neither new framework has translations yet, so both adapters ship the two message sets themselves, with PHP's message keys, ready to move to the framework's i18n once it exists. Neither framework has a request locale either. The locale comes from CODICEFISCALE_LOCALE, and a rule can override it (.locale(Locale::It) in Rust, .Locale(laravelcf.Italian) in Go), so a form offered in both languages needs one input type per language.
Configuration followed what each framework offers. The Rust adapter has a config section read from the environment, message overrides included. Laravel Go has no config files, so the Go adapter reads its settings from the environment and takes message overrides in code, as options of the package. Neither framework has package auto-discovery, so the provider is added by hand in Rust and the package in bootstrap/app.go in Go.
Proving parity: the golden corpus
The ports had to behave exactly like PHP 3.x, and a hand-ported test suite only proves that the port agrees with whoever ported the tests. So the Rust port started with an export script in the PHP repository. It runs the PHP code over a set of inputs and writes the results as JSON, the golden corpus:
1{"input": "RSSMRA05T01H837U", "reference_date": "2026-12-01", "max_age": 120, "valid": false, "errors": ["birth_place_not_attributable"]}
The corpus has two files. structural.json holds 740 cases of format, check character and omocodia. domain.json holds 1,147 cases in seven sections: the dataset built from PHP's fixture files, birthplace resolution, name search, parsing, validation, generation and matching. Its header records the PHP version and commit (3.3.0, a66afc9) and the sha256 of every fixture file. Both ports assert every case, and the Rust and Go copies of both files are identical.
Three rules from the decision record made it work:
- nobody edits the corpus by hand, and regenerating it from PHP is the only way to change what parity means;
- when a hand-ported test and the corpus disagree, the corpus wins;
- every case whose result depends on the date carries an explicit reference date, so the corpus never goes stale.
There is a second layer on top. The Rust core has a round-trip test over 4,800 generated people (20 years, 4 dates, 5 names, some with apostrophes and accents, 6 places, 2 genders): each generated code must validate, parse back to the same person and match. The Go showcase pins 55 requests, from pages to htmx fragments to validation failures, byte for byte against the HTML the Rust showcase serves, once the CSRF token and the edition year are masked.
The corpus has limits, and I asked the agent to spell them out. It covers the core: the adapters' parity rests on ported tests and on message texts copied from PHP's language files. It runs on PHP's fixture samples, and the ANPR sample has three municipalities, so nobody compared the ports with PHP on the full government data. An agent chose the cases, so coverage is as wide as those choices. And a few edges have no PHP behind them: both ports reject years before 0 in generation, which PHP doesn't check.
The port also gave something back to PHP. While preparing the Rust port, the agent noticed that the failure birth_place_not_valid_on_date was named after a rule the package had already replaced: a birthplace code is judged by whether it can be attributed to someone born on that date. PHP 3.3.0 renamed it birth_place_not_attributable, keeping the old key as a deprecated alias until 4.0, and the corpus was regenerated from that release during the Rust port. The export script stayed in the PHP repository, so any future PHP change can be pushed to both ports by regenerating one file.
When the tests didn't test
Each ticket was supposed to be implemented red-first: a failing test, then the code. After the Go port was merged, a look at the subagent runs showed that seven of the twelve code tickets had been done without invoking the TDD skill, and three of them never ran a failing test. The /goal hook kept flagging the same gap.
A test that was never red can pass for the wrong reason, so I chose to have the work checked with mutations. For each affected ticket, a fresh agent changed the production code one line at a time, recorded which changes no test noticed, and covered each real gap with a test that fails with the mutation and passes without it. Two rounds made about 290 mutations and closed about 70 gaps, from XLSX parsing edge cases to the order in which sources override each other. The release scripts had no tests at all, and the new harness found a script that reported a failing check as skipped.
The second round also found a real bug. The Go faker picked a birthplace among the ten known ones before looking at the reference date, so a reference date earlier than the place's start (in that list, Venezia is valid from 1999-04-17) gave an empty date range and a panic. A related issue showed up while fixing it: for a reference date before 2000, the faker could generate a birth in Torino between 1889 and 1899, and that code failed validation with invalid_date, because a two-digit year never resolves before 1900. The Rust faker had the same logic. Both ports now draw only among the places valid on the reference date, keep birth dates from 1900 on, and panic with a clear message before 1889-08-12, when no known place exists yet. Rust 0.1.1 and Go v0.1.1 shipped the fix the same day, with the same output as before for every reference date from 2000 on. PHP's provider takes no reference date, so this bug lived only in the ports.
Porting the showcase
Each version has a showcase app that calculates and decodes codici fiscali, live for PHP, Rust and Go. The PHP one is built with Livewire and Flux. Laravel for Rust 0.1 has no Livewire equivalent, so the Rust showcase renders MiniJinja views and uses htmx to swap fragments returned by ordinary handlers, with Alpine for tabs and tooltips. This keeps Livewire's server-driven model: no JSON API, and every computation stays on the server. Flux's tabs and combobox were rebuilt by hand with Alpine.
The Go showcase is a copy of the Rust one with html/template, and the byte-for-byte test against Rust surfaced the differences between the frameworks:
html/templateescapes quotes as'and", where MiniJinja writes'and", so the views use a small escape helper with the Rust table;csrfFieldaddsautocomplete="off", so the forms write the hidden_tokeninput by hand;- the framework's test client sends
Sec-Fetch-Site: same-origin, which makes the CSRF middleware skip the token check, so the CSRF tests replay a production-like request through a real listener; - the skeleton's
.env.examplesaysSESSION_DRIVER=databaseand the queue defaults todatabasewhenDATABASE_URLis set, so the image sets the cookie session driver and the sync queue, as the Rust app runs.
The Go app was scaffolded by hand from the laravel/go skeleton, because the laravel installer on my machine (0.3.0) has no --go option.
Release and deploy
Most of the friction was at the edges, after the code was done:
- Go checksum database. After a new tag,
sum.golang.organswered 404 for several minutes whileproxy.golang.orgalready served the module. The fix is to wait, and never re-tag. - Go workspace. A committed
go.work(Go 1.27) let the adapter build against the unpublished core, and broke the core's Go 1.23 build. The core is checked withGOWORK=off, and a CI gate refuses to tag the adapter until the core version it needs is on the proxy. - Test-only driver. The SQLite driver for the round-trip test of the model fields raised the core's Go version, so that test lives in a separate test-only module.
- crates.io. The adapter's publish dry run fails until the core is published, and the first publish of 0.1.1 got a 403 from a token without the permissions it needed.
- Render, Rust. Without
APP_URL, theTrustHostsmiddleware answered 400 to every page, while the/uphealth check stayed green. - Render, Go. Docker buildx exports an OTLP endpoint that Laravel Go rejects at boot, which broke the dataset step of the image build until the Dockerfile unset it.
Takeaways
The golden corpus carried most of the weight. It turned parity into a test, the second port reused it unchanged, and it keeps working: a PHP change becomes a regenerated file that both ports have to pass.
The agents wrote each port in less than two hours of commits, and they also skipped a step of the process. The TDD that never happened was caught after the merge and repaired with mutations, and the one real bug came out of that repair.
The two ports felt similar, but Go felt more natural for a Laravel package. The cast shows why: the core type implements two standard interfaces and becomes a model field, where Rust needs a wrapper type for the orphan rule and a second one for the lenient read. More generally, plain structs and functions read closer to PHP than traits, lifetimes and async rules.
I will maintain all three. I am not an expert in Rust or Go, and a lot of the choices in the ports were proposed by an agent and accepted by me. I want to review them, and the 16 decision records in each repository make that practical: each one states a choice and the options it rejected. If you know Rust or Go and one of them looks wrong, open an issue on laravel-codicefiscale-rs or laravel-codicefiscale-go.
Get the next posts by email
An occasional newsletter with my new Posts, with one-click unsubscribe. How I handle your address.