mtarld/json-encoder-bundle
Symfony bundle that integrates mtarld/json-encoder into your app, letting you encode and decode PHP objects to and from JSON with support for denormalization, validation, and typed collections.
Architecture fit. This is a Symfony bundle, not a framework-agnostic library. Its value proposition is compile-time generation of JSON encoders/decoders from PHP class attributes, eliminating the runtime reflection cost that Symfony Serializer, JMS Serializer, and Laravel's own JsonResource layer incur. That's a real but narrow benefit. The architectural mismatch is significant: Laravel has no bundle system, no kernel compiler passes, and no container compilation phase analogous to Symfony's. The bundle's core mechanism—a DI compiler pass that walks the codebase and emits encoder classes—has no natural insertion point in a Laravel lifecycle. In practice you would not install this bundle at all; you would reach for the underlying mtarld/json-encoder package and hand-wire generation as a build step. At that point you're maintaining an integration the author never designed or documented.
Integration feasibility. Feasible but manual. Attributes live on domain/DTO classes; a Composer script or artisan command invokes the generator; output is autoloaded and registered in a service provider. Laravel's container resolves by class name, so wiring works. There is no Laravel service provider, no config file, no Laravel-oriented documentation, and zero evidence anyone has done this. Expect a spike to surface issues the package author never encountered.
Technical risk: high. Four independent signals compound here: archived repository (no patches, no PHP 8.4/8.5 guarantees, no fixes for breaking transitive dependencies like nikic/php-parser), 10 stars, zero dependents, and a score of 0.04. That combination means no community validation, no StackOverflow answers, no third-party battle testing, and a bus factor of one—who has already stopped. Code generation also introduces a build artifact that must be regenerated deterministically and kept in sync with model changes; drift is a silent failure mode.
Key questions.
Stack fit. Poor to moderate. Symfony-native, Laravel-adjacent. Laravel 10/11 on PHP 8.1–8.3 is probably workable for the standalone generator; anything newer is unverified. The honest comparison set is Illuminate\Http\Resources, spatie/laravel-data, a Symfony Serializer bridge, or hand-written hydrators. Evaluate those first—they are maintained and staffed by people other than us.
Migration path. If pursued: add mtarld/json-encoder as a require-dev, run generation in CI via a Composer script or artisan command, emit into a dedicated namespace, register generated classes in a service provider. Do not attempt to load the bundle itself in Laravel—the bundle registration and kernel wiring will not resolve. If we are already on Symfony Serializer or API Resources, this is a parallel path, not a migration; that doubles the serialization surface and should be a hard stop.
Compatibility. Archived as of March 2024. Pinned Symfony and parser dependency ranges will likely conflict with current Symfony 7.x and Laravel 11.x releases. Composer resolution failures mid-project are the expected first incident, not a tail risk.
Sequencing.
Recommendation: do not adopt for production. Treat as a reference implementation or a benchmark baseline. If generated serializers are genuinely required for performance, fund an internal fork with a named owner and explicit exit criteria, or select a maintained library.
Maintenance. Archived means we own it outright. Budget for a fork, version pins, and periodic patching for PHP minors and transitive CVEs—none of which appears in any vendor roadmap. The regeneration step becomes a permanent CI obligation with an owner and code review, since generated code is reviewed like hand-written code or it isn't reviewed at all.
Support. No upstream triage, no issue responses, no security advisories. Escalation is internal only, which concentrates risk in whichever engineer learns the generator internals. That person's departure is a project-level event.
Scaling. Technically fine—generated encoders are stateless and fast, which is the entire point. Generation time grows linearly with model count and won't matter at realistic sizes. Organizationally it does not scale: no docs, no examples, no community to consult. Every new hire ramps from source code.
Failure modes.
Ramp-up. Three to five days for a senior PHP engineer to be productive; longer to be confident. The mental model is simple, but with no documentation the learning is archaeological. Onboarding cost stays elevated for the life of the dependency because there is nothing external to point people at.
How can I help you explore Laravel packages today?