fasano/phprimitives
fasano/phprimitives provides strongly-typed, immutable wrappers for PHP primitives, turning strings, numbers, booleans, and arrays into self-validating value objects with a clean, chainable API for safer data handling in PHP and Laravel apps.
Architecture fit. The package (evidenced by InvalidBackingValue, characteristic of backed value objects / enum-backed scalars) is a framework-agnostic PHP primitives library, not a Laravel extension. It lands in the domain layer rather than infrastructure, which is the right place for it — but it also means it becomes load-bearing across models, DTOs, and validation boundaries. Adopt it deliberately as a domain convention, not as an incidental utility dependency.
Integration feasibility. Standard Composer install; no service provider, config publishing, or facade implied. Integration effort is low and reversible. The real work is convention-setting, not wiring.
Technical risk. v1.0.2 is a patch release with a single change: removal of the FQCN from InvalidBackingValue's message. This is not an API break — the exception class, constructor, and throw sites are unchanged — but it is an observable behavior change at the message-string level:
$e::class, not just $e->getMessage()).Key questions.
InvalidBackingValue, and do any tests or log queries assert on the message text?composer audit history, issue/PR responsiveness, release recency.Stack fit. composer require n-fasano/phprimitives. Treated as a plain library — no framework coupling, so it works identically in HTTP handlers, queue workers, console commands, and tests. It cannot leak HTTP-layer concerns into the domain, which is the main architectural argument for it.
Migration path. Greenfield adoption is trivial. For an existing codebase, introduce incrementally at the edges — request validation into domain construction — rather than a big-bang replacement of existing casts and accessors. Verify before assuming Eloquent integration: the package is not a cast provider, so $casts integration requires a custom cast wrapper on our side.
Compatibility. Pin with caret (^1.0) and commit composer.lock. Confirm the PHP constraint against our runtime matrix and against every Laravel major we support. Run composer audit in CI so upstream advisories surface without manual checking.
Sequencing.
InvalidBackingValue to a domain/validation error in the exception handler and log $e::class explicitly so the FQCN-free message doesn't degrade observability.Maintenance. Small surface area, low upgrade cost per release — budget minutes, not days. The overhead is administrative: add to the dependency register, watch releases, and expect frequent small patch bumps given the current cadence.
Support. GitHub issues only; no commercial backing and a single maintainer. Name an internal owner for the value-object convention — upstream will not supply that guidance.
Scaling. No runtime scaling concerns; value objects are in-process and allocation-cheap. The scaling cost is cognitive: onboarding engineers to the primitive set and its exception semantics. Document once, reuse.
Failure modes.
InvalidBackingValue on production paths producing 500s instead of 422s if no exception mapping exists.Ramp-up. Hours for a PHP-fluent engineer; the constraint is agreeing on the convention, not learning the API.
Release verdict. v1.0.2 does not change adoption guidance — non-breaking, no new capability, no deprecation. Action required is narrow: grep the codebase for assertions or log queries matching InvalidBackingValue message text before bumping.
How can I help you explore Laravel packages today?