spatie/typed
Userland improved PHP type system with type inference and runtime checking: generics, union types, typed collections/lists, tuples, and structs. Proof-of-concept package from Spatie to add stronger type guarantees without language-level support.
spatie/typed enables teams to leverage stricter type safety in PHP/Laravel, reducing runtime errors and improving code maintainability. This aligns with roadmaps prioritizing developer experience (DX) and reducing technical debt.Adopt When:
Look Elsewhere If:
phpstan/extension-installer or rector).array<Key, Value> syntax).For Executives:
"This package lets our PHP/Laravel teams write more reliable code with fewer bugs—like adding a ‘type checker’ for complex data structures without switching languages. For example, it lets us enforce rules like ‘this API response must always include a userId and timestamp tuple,’ catching errors early. It’s a lightweight upgrade that aligns with our tech debt reduction goals and scales with our move into microservices. The tradeoff? A small learning curve for developers, but the payoff is fewer production fires and faster onboarding for new hires."
For Engineering:
"Spatie’s typed fills critical gaps in PHP’s type system (generics, structs, tuples) that we’d otherwise have to build manually or ignore. For instance:
__get() DTOs with compile-time safety (e.g., UserStruct::fromArray($data)).(string, int) for UserId + Timestamp) without hacks.List<User>) for repositories or caching layers.
It’s archived but stable—we’d pair it with PHPStan for full static analysis. The effort to adopt is low (1–2 dev days), and the ROI is higher confidence in refactors and new features. Alternatives like phpstan are heavier; this is the ‘just enough’ solution."How can I help you explore Laravel packages today?