phrity/util-transformer
Type transformers, normalizers, and resolvers for PHP. Convert values between types, encode and decode JSON, flatten nested arrays, and stack transformers with recursion and first-match resolvers for flexible data transformation.
DateTime, enums, JsonSerializable, Stringable, and Throwable to standardize JSON/API output and reduce endpoint-specific serialization code. PM value: fewer contract inconsistencies and less glue code in non-core features.JsonDecoder, FlattenDecoder, Readable/ReversedReadable, and resolver pipelines to normalize webhook payloads, import files, form-request data, or configuration before validation. PM value: faster delivery for integration-heavy features.ThrowableConverter to produce consistent error envelopes for logs, APIs, or support tooling. PM value: improved observability without a bespoke formatting subsystem.TransformerService/adapter, not directly on phrity/util-transformer. This preserves exit options and prevents a tiny dependency from becoming an implicit platform standard.Consider it when:
DateTime, enums, JsonSerializable, Stringable, booleans/null readability, and exception formatting.FirstMatchResolver, ChainedResolver, RecursionResolver, StringResolver) fits heterogeneous payloads better than scattered if/switch conversion logic.Look elsewhere when:
spatie/laravel-data, or similar for core API contracts.For executives: This is a small MIT utility that can reduce custom glue code for API serialization, payload normalization, and error formatting. It is inexpensive to trial, but it has very low adoption and should not become a strategic platform dependency. Recommendation: approve a time-boxed pilot behind an internal adapter, measure reduced boilerplate and defect rate on one or two non-critical flows, and keep a fallback to Laravel/Symfony-native tooling.
For engineering: Adopt it only as an implementation detail for non-core type conversion. Register resolvers through a service provider, expose an internal transformer interface, pin the package version, and add contract tests for supported types and failure modes. Use FirstMatchResolver/RecursionResolver for heterogeneous payloads only with depth/size limits. Prefer Laravel API Resources or Symfony Serializer for core API contracts, and document exactly which types and fallbacks are supported before expanding usage.
How can I help you explore Laravel packages today?