Sulat.com / Writing on AIFriday, December 4, 2026
Enter →
Agent Engineering/4 December 2026

A hands-on guide to Spatie’s Go packages

Spatie says it ported 44 PHP packages to Go the day after Laravel Go launched. I installed nine, checked them against the PHP originals and timed four.

Spatie logo tile and a Go tile joined by a bridge of stacked cardboard package boxes
Illustration: Sulat, featuring the Spatie logo

At a glance

  • Spatie has ported 44 PHP packages to Go: 26 for Laravel Go and 18 that need no framework, all tagged in the 0.1 series.
  • The Go URL signer matched the real PHP package on 2,053 signed URLs and 42,870 validation outcomes.
  • Holiday calendars matched PHP in 309 of 315 cases for 105 countries, and the two differences are one Greek date in 2024.
  • Go ran holiday lookups about 16.6 times faster than PHP and period and opening-hours queries about ten times faster, but the URL signer only 1.2 times faster.
  • The packages need Go 1.27 or newer, and every release is a patch of v0.1, so pin the exact version.

Spatie says it ported 44 of its PHP packages to Go the day after Laravel Go launched. I installed nine of them, ran their test suites, checked two against the PHP originals and timed four. Everything I ran worked, the Go ports match PHP almost exactly, and how much faster they are depends on the job.

What Spatie announced

Freek Van der Herten posted the announcement on 3 December. Spatie ported 26 packages for Laravel Go, including Media Library and Permission, and 18 that need no framework, including Opening Hours, Period and Holidays. All 44 have tagged releases in the 0.1 series. The Rust round came two days earlier, with 27 crates published at 0.1.0 and a few more on GitHub only.

Stat diagram: 44 Spatie Go packages, 26 for Laravel Go and 18 that work without Laravel
Of the 44 packages, 26 plug into Laravel Go and 18 run on their own. Illustration: Sulat

Spatie credits its process for the speed. The team built its Rust packages with AI, and that work left a repeatable way to brief the agent, define what a finished package looks like, and handle the README, docs and website listing around the code. In the post’s words:

The work we’d done on the Rust packages had given us a way of doing this that we could use again.

Freek Van der Herten, Spatie

Spatie also points at what the agent started from: years of PHP code, tests and documentation, with APIs that real use had already reshaped. It’s frank about the result. “We’re not Go experts yet,” the post says, and “These are early releases, not stable ones.” It suggests trying the packages in a side project first and expects APIs to change.

How the ports are built

The repositories show how that works. Each one carries an AGENTS.md file for coding agents, and the rule that matters most is in its second paragraph:

PHP behavior and customization points define a port’s contract. Rust ports are implementation references, not proof of PHP parity.

AGENTS.md in spatie/url-signer-go
Diagram: PHP code and tests, PHP docs and the Rust port feed into a Go package, with PHP behaviour as the contract
The PHP package defines how the Go port must behave. The Rust port is only a reference. Illustration: Sulat

AGENTS.md points to a skill file at .agents/skills/writing-spatie-go-packages/SKILL.md. It tells the agent to read the PHP source, config, extension classes, tests and docs first, write a behaviour checklist, and only then read the Rust port. Tests live beside the code, use real replacement implementations rather than mocks of private helpers, and every public feature gets an executable example. The url-signer repository goes further: its testdata/oracle.php loads the real PHP package at a pinned commit and compares results with the Go code.

The release rule explains the version numbers. The first release is v0.1.0 and every later release is the next patch, even a breaking one. On the Go module proxy I found 16 packages at v0.1.0, 21 at v0.1.1 and seven at v0.1.2. Pin the exact version you test.

What I ran

Everything ran on one cloud machine with four Intel Xeon cores at 2.3 GHz under KVM, 16 GB of memory, a 252 GB disk and Ubuntu 24.04. Go was 1.27.4. PHP was 8.3.6 on the command line with no opcache, with the current Composer releases of the PHP packages. I tested nine of the 44 packages: eight that need no framework and one for Laravel Go. I haven’t run the other 35.

PackageVersionWhat I ranResult
url-signer-gov0.1.1Own tests, PHP differential test, speedMatched PHP on every case
holidays-gov0.1.2Own tests, 105-country comparison, speed309 of 315 calendars identical
period-gov0.1.0Own tests, speedPassed
opening-hours-gov0.1.0Own tests, speedPassed
calendar-links-gov0.1.0Own tests, demo programPassed
schema-org-gov0.1.1Own tests, demo programPassed
robots-txt-gov0.1.0Own tests, demo programPassed
ssl-certificate-gov0.1.0Own testsPassed
laravel-honeypot-gov0.1.1Live Laravel Go app, five requestsBehaved as documented
What I ran against each package.

The full guide

1. Get Go 1.27.4

The packages need Go 1.27 or newer. My machine shipped Go 1.24.7, so I pulled the toolchain by exact version. Setting GOTOOLCHAIN=go1.27 is rejected because that’s a language version, while go1.27.4 works.

Code
export GOTOOLCHAIN=go1.27.4
go version

2. Install with a pinned version

Code
go mod init myapp
go get github.com/spatie/[email protected] github.com/spatie/[email protected] github.com/spatie/[email protected]
Terminal showing go get adding three Spatie Go packages to a fresh module on Go 1.27.4
Three go get lines and the packages are in a fresh module.

3. Use seven packages in one program

This program asks whether a shop is open on a Friday evening in Auckland, lists New Zealand’s public holidays for the end of 2026, compares two date ranges, builds an add-to-calendar link, prints JSON-LD for a local business, signs and validates a download link, and checks a robots.txt rule. It compiled after one fix to a method name.

Code
package main

import (
	"fmt"
	"time"

	calendarlinks "github.com/spatie/calendar-links-go"
	"github.com/spatie/holidays-go"
	openinghours "github.com/spatie/opening-hours-go"
	"github.com/spatie/period-go"
	robots "github.com/spatie/robots-txt-go"
	schema "github.com/spatie/schema-org-go"
	urlsigner "github.com/spatie/url-signer-go"
)

func must[T any](v T, err error) T {
	if err != nil {
		panic(err)
	}
	return v
}

func main() {
	// Opening hours
	hours := must(openinghours.ParseJSON([]byte(`{
		"monday": ["09:00-17:00"], "tuesday": ["09:00-17:00"],
		"wednesday": ["09:00-17:00"], "thursday": ["09:00-17:00"],
		"friday": ["09:00-17:00"], "saturday": [], "sunday": [],
		"exceptions": {"12-25": [], "12-26": []}
	}`)))
	loc := must(time.LoadLocation("Pacific/Auckland"))
	now := time.Date(2026, 12, 4, 18, 30, 0, 0, loc)
	fmt.Println("== opening-hours-go")
	fmt.Println("Open Friday 6:30 PM?", hours.IsOpenAt(now))
	fmt.Println("Next open:", must(hours.NextOpen(now)).Format("Monday 15:04 2 Jan"))
	xmas := time.Date(2026, 12, 25, 10, 0, 0, 0, loc)
	fmt.Println("Open Christmas Day?", hours.IsOpenAt(xmas))

	// Holidays
	fmt.Println("== holidays-go (NZ 2026)")
	for _, h := range must(holidays.Get("nz", 2026)) {
		if h.Date.Month() >= 10 {
			fmt.Println(h.Date.Format("2006-01-02"), h.Name)
		}
	}

	// Period
	fmt.Println("== period-go")
	a := must(period.Parse("2026-12-01", "2026-12-20"))
	b := must(period.Parse("2026-12-15", "2027-01-10"))
	fmt.Println("A:", a, "length", a.Length(), "days")
	fmt.Println("B:", b)
	ov, _ := a.OverlapsWith(b); fmt.Println("Overlaps:", ov)

	// Calendar link
	fmt.Println("== calendar-links-go")
	ev := must(calendarlinks.New("Sulat test day",
		time.Date(2026, 12, 10, 10, 0, 0, 0, loc),
		time.Date(2026, 12, 10, 12, 0, 0, 0, loc)))
	fmt.Println(ev.Google())

	// Schema
	fmt.Println("== schema-org-go")
	biz := schema.LocalBusiness().Name("Harbour Books").Email("[email protected]")
	fmt.Println(must(biz.ToScript()))

	// URL signer
	fmt.Println("== url-signer-go")
	signed := must(urlsigner.Sign("demo-key-123", "https://example.com/download/42", 30*time.Second))
	fmt.Println(signed)
	s := must(urlsigner.New("demo-key-123"))
	fmt.Println("valid:", s.Validate(signed))
	fmt.Println("tampered valid:", s.Validate(signed+"x"))

	// Robots
	fmt.Println("== robots-txt-go")
	txt := robots.ParseTxt("User-agent: *\nDisallow: /admin\nCrawl-delay: 1.5\n")
	fmt.Println("/admin allowed:", txt.Allows("/admin", "googlebot"), "| /blog allowed:", txt.Allows("/blog", "googlebot"))
}
Terminal output of one Go program using opening hours, holidays, period, calendar links, schema, URL signer and robots packages
One small program, seven Spatie packages, plain output.

The output reads the way the PHP versions do. The shop is closed at 6:30 PM on Friday, the next opening is Monday at 9:00, and Christmas Day is closed because of the exception. New Zealand’s list ends with Labour Day on 26 October, Christmas Day, and Boxing Day moved to Monday 28 December. The signed link validated, and the same link with one extra character didn’t.

4. Run each package’s own tests

Module cache files are read-only, so copy a package out first. Then run its suite with the race detector on.

Code
cp -r $(go env GOMODCACHE)/github.com/spatie/[email protected] period-go
chmod -R u+w period-go
cd period-go && go test -race ./...
Terminal showing eight Spatie Go packages passing their own go test -race suites
All eight test suites passed with the race detector on.

All eight passed. The holidays suite took about 81 seconds and the others about a second each.

5. Check the port against PHP

The URL signer is the one package here that comes with a live comparison against PHP. I cloned the PHP package at the commit its docs name, copied the Go module out of the cache and pointed the test at the checkout.

Code
git clone https://github.com/spatie/url-signer.git url-signer-ref
git -C url-signer-ref checkout 3cddceff31fcbffc19ee21e5abf7cbf6c196292e
cd url-signer-go
PHP_URL_SIGNER_SOURCE=/path/to/url-signer-ref go test -race -run TestPHPDifferential -v
Terminal: URL signer differential test matching 2053 signed URLs and 42870 validation outcomes against PHP
The Go URL signer matched the real PHP package on every case.

It compared 2,053 signed URLs and 42,870 validation outcomes, and Go matched PHP on all of them. That includes links signed in PHP and validated in Go, which matters if you migrate one service at a time.

Holidays has no live test, so I built one. The Go package supports 105 country codes and its docs name the PHP commit it follows. I generated every calendar for 2024, 2026 and 2030 from both sides, 315 in total, and compared dates and names. 309 were identical, four returned an error in both, and two differed.

Terminal: 315 holiday calendars compared, 309 identical, 2 differ for Greece in 2024, 4 error in both
Holiday calendars matched PHP in 309 of 315 cases, and one Greek date differs.

Both differences are Greece in 2024. Go gives Labour Day as 7 May and PHP gives 1 May. The two codebases contain the same rule, which moves the holiday when 1 May falls in Holy Week. Orthodox Easter in 2024 was on 5 May, so the rule applies, and Go applied it. The reference commit uses PHP 8.4 syntax, so I ran it on PHP 8.3 after wrapping a few new expressions in parentheses, a syntax-only change. The cause is on the PHP side. Its Easter date carries the current clock time, and the rule compares it with midnight on 1 May using a loose equality check, so the match fails unless the code runs at exactly midnight. Go compares dates only, so it applies the rule as written.

6. Time it against PHP

I timed four operations in both languages: sign and validate a URL, fetch New Zealand’s 2026 holidays, overlap two periods, and ask for the next opening time. Each ran in a single loop on one core, after one warm-up call, and I took the median of three runs. This is the Go side:

Code
package main

import (
	"fmt"
	"strconv"
	"time"

	"github.com/spatie/holidays-go"
	openinghours "github.com/spatie/opening-hours-go"
	"github.com/spatie/period-go"
	urlsigner "github.com/spatie/url-signer-go"
)

func t(name string, n int, f func(i int)) {
	f(0)
	s := time.Now()
	for i := 0; i < n; i++ {
		f(i)
	}
	e := time.Since(s).Seconds()
	fmt.Printf("%-28s %9d ops %8.3f s %12.0f ops/s\n", name, n, e, float64(n)/e)
}

func main() {
	signer, _ := urlsigner.New("demo-key-123")
	t("urlsigner sign+validate", 100000, func(i int) {
		u, _ := signer.Sign("https://example.com/download/"+strconv.Itoa(i), 30*time.Second)
		signer.Validate(u)
	})
	t("holidays nz 2026", 2000, func(i int) { holidays.Get("nz", 2026) })
	a, _ := period.Parse("2026-12-01", "2026-12-20")
	b, _ := period.Parse("2026-12-15", "2027-01-10")
	t("period overlap", 100000, func(i int) { a.Overlap(b) })
	hours, _ := openinghours.ParseJSON([]byte(`{"monday":["09:00-17:00"],"tuesday":["09:00-17:00"],"wednesday":["09:00-17:00"],"thursday":["09:00-17:00"],"friday":["09:00-17:00"],"saturday":[],"sunday":[],"exceptions":{"12-25":[],"12-26":[]}}`))
	loc, _ := time.LoadLocation("Pacific/Auckland")
	d := time.Date(2026, 12, 4, 18, 30, 0, 0, loc)
	t("opening-hours nextOpen", 50000, func(i int) { hours.NextOpen(d) })
}

And the PHP side, using spatie/url-signer 2.2.0, holidays 1.24.0, period 2.4.3 and opening-hours 4.2.5:

Code
<?php
require __DIR__.'/vendor/autoload.php';
use Spatie\UrlSigner\Sha256UrlSigner;
use Spatie\Holidays\Holidays;
use Spatie\Period\Period;
use Spatie\OpeningHours\OpeningHours;
function t($name,$n,$f){ $f(); $s=hrtime(true); for($i=0;$i<$n;$i++){$f($i);} $e=(hrtime(true)-$s)/1e9; printf("%-28s %9d ops %8.3f s %12.0f ops/s\n",$name,$n,$e,$n/$e);}
$signer = new Sha256UrlSigner('demo-key-123');
t('urlsigner sign+validate',100000,function($i=0) use($signer){ $u=$signer->sign('https://example.com/download/'.$i,30); $signer->validate($u);});
t('holidays nz 2026',2000,function($i=0){ Holidays::for('nz',2026)->get();});
$a=Period::make('2026-12-01','2026-12-20'); $b=Period::make('2026-12-15','2027-01-10');
t('period overlap',100000,function($i=0) use($a,$b){ $a->overlap($b);});
$oh=OpeningHours::create(['monday'=>['09:00-17:00'],'tuesday'=>['09:00-17:00'],'wednesday'=>['09:00-17:00'],'thursday'=>['09:00-17:00'],'friday'=>['09:00-17:00'],'saturday'=>[],'sunday'=>[],'exceptions'=>['12-25'=>[],'12-26'=>[]]]);
$d=new DateTimeImmutable('2026-12-04 18:30:00', new DateTimeZone('Pacific/Auckland'));
t('opening-hours nextOpen',50000,function($i=0) use($oh,$d){ $oh->nextOpen($d);});
Terminal table of operations per second for Spatie PHP and Go packages: URL signer, holidays, period overlap, opening hours
Median of three runs on the same four-core machine.
Bar chart: Go package speed over PHP, holidays 16.6x, period overlap 10.7x, opening hours 10.4x, URL signer 1.2x
Three of four operations ran about ten times faster or more in Go. The URL signer barely moved. Illustration: Sulat

Holiday lookups ran about 16.6 times faster in Go. Period overlap and the opening-hours next-open query ran about ten times faster. The URL signer, which signs and validates a link, was only about 1.2 times faster, and I didn’t profile it. PHP ran without opcache, so a tuned PHP server will close part of the gap on the other three.

7. Add a Laravel Go package

Laravel Go packages take one more step, because they register with the framework. I used the honeypot package, which hides two form fields and rejects submissions that fill the trap, arrive too fast or lack the fields. The package docs require go.laravel.com v0.1.0, and nothing activates until you list the package in the app options and attach its middleware to a route. I set FieldsRequired and returned a 422 so each rejection is easy to read.

Code
go mod init lapp
go get github.com/spatie/[email protected] [email protected]
go mod tidy
go build -o lapp .
Code
package main

import (
	"log"
	"net/http"
	"testing/fstest"

	honeypot "github.com/spatie/laravel-honeypot-go"
	laravel "go.laravel.com"
	"go.laravel.com/config"
	"go.laravel.com/crypt"
	"go.laravel.com/routing"
	"go.laravel.com/web"
)

func main() {
	app, err := laravel.New(laravel.Options{
		Env: config.NewEnv(map[string]string{"APP_KEY": crypt.GenerateKey(crypt.AES256CBC)}),
		Packages: []laravel.Package{honeypot.New(func(cfg *honeypot.Config) {
			cfg.FieldsRequired = true
			cfg.Responder = func(r *web.Request, next web.Next) *web.Response {
				return web.Text("Looks like spam.").WithStatus(422)
			}
		})},
		Views: fstest.MapFS{"contact.html": {Data: []byte(
			`<form method="POST" action="/contact">{{honeypot}}<input name="email"><button>Send</button></form>`)}},
		Routes: laravel.Routes{Bare: func(route *routing.Router, _ *config.Config) {
			route.Get("/contact", func(*web.Request) *web.Response { return web.View("contact", nil) })
			route.Post("/contact", func(r *web.Request) *web.Response {
				return web.Text("Thanks for your message!")
			}).Middleware(honeypot.ProtectAgainstSpam{})
		}},
	})
	if err != nil {
		log.Fatal(err)
	}
	defer app.Close()
	log.Println("listening on :8099")
	log.Fatal(http.ListenAndServe(":8099", app))
}

I started the server and sent five requests with this script. It reads the hidden field names from the rendered form, so each request uses the real token.

Code
#!/bin/bash
B=http://localhost:8099
page=$(curl -s $B/contact)
echo "--- GET /contact"; echo "$page"
trap=$(echo "$page" | grep -o 'name="my_name_[^"]*"' | head -1 | cut -d'"' -f2)
tok=$(echo "$page" | grep -o 'name="valid_from" type="text" value="[^"]*"' | sed 's/.*value="//;s/"$//')
echo
echo "--- 1. submit straight away (under 1 second)"
curl -s -o - -w " [HTTP %{http_code}]\n" -d "$trap=" --data-urlencode "valid_from=$tok" -d "[email protected]" $B/contact
echo "--- 2. wait 2 seconds, submit"
sleep 2
curl -s -o - -w " [HTTP %{http_code}]\n" -d "$trap=" --data-urlencode "valid_from=$tok" -d "[email protected]" $B/contact
echo "--- 3. bot fills the hidden field"
curl -s -o - -w " [HTTP %{http_code}]\n" -d "$trap=gotcha" --data-urlencode "valid_from=$tok" -d "[email protected]" $B/contact
echo "--- 4. bot omits both honeypot fields"
curl -s -o - -w " [HTTP %{http_code}]\n" -d "[email protected]" $B/contact
echo "--- 5. tampered token"
curl -s -o - -w " [HTTP %{http_code}]\n" -d "$trap=" --data-urlencode "valid_from=${tok}x" -d "[email protected]" $B/contact
Terminal: Laravel Go form with honeypot fields, five requests, one accepted with HTTP 200 and four rejected with 422
The rendered form and the five responses, as the server returned them. The token is shortened here.
Checklist: honeypot form rejected under a second, filled field, missing fields and tampered token; accepted after two seconds
Only the patient, honest submission got through. Illustration: Sulat

Only the submission that waited two seconds was accepted. The package’s docs add two warnings. The default lets a request through when both fields are absent, so turn FieldsRequired on for login and registration forms. And tokens don’t expire, so keep CSRF protection and rate limits in place.

Where the Go packages sit

Against the Rust ports, the Go round is more complete on release day. Spatie published 27 crates for Rust and left others on GitHub only, while all 44 Go packages are tagged. Spatie’s own Rust work started with Ray 4, the debugging app it rewrote in Rust, which we covered in Spatie rewrites Ray in Rust.

Against the PHP originals, the Go packages aren’t a replacement. Spatie says its PHP and Rust packages remain supported and that the Go set is “another set of packages you can choose from, not a reason to move an existing application.” The PHP packages have years of production use behind them, and Spatie’s own post says the Go ports don’t have that track record yet.

For Laravel Go itself, the ports fill a gap. A framework that launched this week now has permissions, media handling, a backup tool, a sitemap generator and webhook clients with APIs Laravel developers already know. Our hands-on guide to Laravel Go covers the framework, and the Laravel Rust guide covers its sibling.

Before you use one

  1. Install Go 1.27.4 or newer and pin the package version, because every release is a patch of v0.1.
  2. Run the package’s own tests inside your module.
  3. If the package has a PHP oracle, run it, as with the URL signer.
  4. Read the docs page on what differs from PHP. Each port lists its changed or unsupported behaviour.
  5. Try it in a side project first, as Spatie asks.

Sources