Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Decoder Laravel Package

karriere/json-decoder

JsonDecoder maps JSON into typed PHP objects, handling nested objects, arrays, scalar casting, required fields, and custom decoders. It turns API responses and config files into predictable, IDE-friendly classes for safer, cleaner PHP code.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. karriere/json-decoder is a framework-agnostic, plain-PHP hydration library: given a JSON string and a target class, it maps keys onto typed properties (docblock/attribute-driven, including nested objects and arrays of objects). That makes it a natural fit for an anti-corruption layer in a Laravel app — e.g., decoding third-party API responses, webhook payloads, or queue message bodies into DTOs before they reach domain services. It is not a fit for Eloquent model hydration, request validation, or anything that expects a Laravel service provider out of the box; there is no Illuminate dependency and therefore no config, facade, or publishable assets. Nothing in v5.1.0 changes this — the release is purely a runtime-support adjustment, not an architectural one.

Integration feasibility. High, but the runtime floor moved. composer require karriere/json-decoder, instantiate the decoder (or bind it as a container singleton), and call decode($json, MyDto::class). No migrations, no middleware, no env vars. As of v5.1.0 the package supports PHP 8.2+ (8.5 added, 8.0 and 8.1 removed), so the prerequisite is now a PHP 8.2 runtime floor rather than the 8.1 assumed previously. PSR-4 autoloading for your DTO namespace remains the only other prerequisite. Any app or CI runner still on 8.1 will fail Composer resolution against this version — pin the last 5.0.x release if you cannot move the runtime.

Technical risk.

  • License: NOASSERTION. Still the first blocker and unchanged by this release. The repository appears to carry an MIT-style license file, but the package metadata does not declare it. Legal must confirm before production use; otherwise treat it as "all rights reserved" by default.
  • Semver hygiene on runtime support. Dropping PHP 8.0/8.1 in a minor (5.1.0) rather than a major is a real, if common, semver violation. It means a routine composer update can silently raise your effective runtime floor. This raises the cost of loose version constraints: pin to ^5.1 deliberately, or to an exact minor, and let Renovate/Dependabot surface bumps for review rather than auto-merging.
  • Maintainer activity — improved signal. Adding PHP 8.5 support within the same release shows the maintainer is tracking the PHP release cycle and is not dormant. That partially offsets the bus-factor concern, though the contributor pool is still small and there is no foundation or commercial backing (140 stars, 0 registered dependents).
  • Opportunity score 24.36 still signals limited ecosystem momentum. Compare against spatie/laravel-data (Laravel-native, large community, validation built in) and symfony/serializer (foundation-backed) before committing broadly. Note that those alternatives have their own PHP-floor cadence, so this is not a differentiator in either direction.
  • Edge-case coverage. Reflection-based mappers vary in support for readonly properties, enums, union/intersection types, nullable nested objects, and unknown-key handling. These still need to be verified empirically — the release notes claim no code-level hydration changes, but "no changelog entry" is not the same as "no behaviour change."
  • Performance characteristics. Unchanged. Reflection on every decode has a measurable cost at high throughput; the library's caching story (if any) needs benchmarking against your payload volumes.

Key questions.

  1. Is the license file legally sufficient, and can we get written clarification from the maintainer?
  2. What is our actual PHP floor across app servers, queue workers, and CI — is anything still on 8.1 or 8.0?
  3. Does the maintainer intend to keep dropping PHP versions in minor releases, or was 5.1.0 a one-off? Is a 6.0 planned?
  4. Were there any code changes behind the version-constraint bump in 5.1.0, or is it a composer.json-only diff? (Confirm via the diff, not the changelog.)
  5. How does it behave on missing keys, extra keys, nulls, and type mismatches — exception, silent null, or coercion?
  6. Does it handle enums, readonly classes, and ?Class nested objects in the version we would pin?
  7. What is the decode throughput versus a hand-written hydrator for our largest expected payload?
  8. Can we accept a single-vendor dependency, or do we need a fork-and-vendor policy?
  9. Does it conflict with anything already in composer.lock (serializer, data-mapper, or validation packages)?

Integration Approach

Stack fit. PHP 8.2+ (8.2–8.5 supported), Composer 2, Laravel 9–12 (implicitly, since the package has no framework coupling — but note Laravel 9 still supports PHP 8.0/8.1, so this package effectively narrows you to Laravel 9.32+ or Laravel 10+). Best placed in an infrastructure layer: an Http/Integrations/<Vendor> namespace where response classes are plain DTOs, consumed by services via an interface. Keep DTOs out of controllers and away from Eloquent.

Migration path. Unchanged in shape and now more clearly justified. Do not sprinkle new JsonDecoder() through the codebase. Define a thin internal contract — e.g. App\Support\Hydration\JsonHydrator with hydrate(string $json, string $class): object — and implement it with this package. That gives three benefits: (a) a single swap point if we later move to spatie/laravel-data or symfony/serializer, (b) a place to add strict-mode validation and logging, and (c) testability with fixture JSON. The v5.1.0 runtime-floor bump is exactly the kind of change the adapter boundary does not protect you from — it is a Composer-level constraint, not an API-level one — so pair the adapter with a pinned version.

Compatibility. No illuminate/* constraints means no version pinning against Laravel, which is good, but also means Laravel compatibility is untested by the maintainer — we own that verification. New in this release: the php constraint is now effectively ^8.2, so run composer why-not karriere/json-decoder 5.1.0 against the lock file and confirm every environment (local, CI, staging, prod, queue workers, scheduled-task containers) meets the floor before bumping. If you build container images, the base image tag must be 8.2 or later — a stale php:8.1-fpm base is the most likely failure point. Add PHP 8.5 to the CI matrix only once the rest of the dependency tree supports it. Keep it in the existing composer audit/license-scan step, and if we already ship symfony/serializer or jms/serializer, confirm there's no class-name or annotation-reader collision.

Sequencing.

  1. Week 0 — Legal/security gate: verify the license text, run a SCA/license scan, confirm no transitive surprises.
  2. Week 0 — Runtime floor audit (new): inventory PHP versions across app, CI, workers, and images; confirm 8.2+ everywhere or scope a runtime upgrade first. Diff 5.0.x → 5.1.0 to confirm the change is constraint-only.
  3. Week 0–1 — Spike (1–2 days): model five representative payloads (flat, nested, array-of-objects, nullable, enum/union) and test round-trip behaviour plus error cases.
  4. Week 1 — Benchmark: 1k/10k decode loop against a hand-rolled hydrator; record p50/p95 and memory.
  5. Week 2 — Adapter + contract tests: implement JsonHydrator, add fixture-based tests, wire the singleton binding, pin the exact version in composer.json (prefer ^5.1 with a reviewed lock, not * or ^5.0).
  6. Week 2–3 — First integration: roll out on one non-critical inbound integration behind a feature flag; monitor error rates.
  7. Week 4 — Decision review: adopt broadly, or revert to the adapter's alternative implementation with zero downstream churn.

Operational Impact

Maintenance. Small code surface, low churn, but the release cadence has now demonstrated a specific pattern: minor releases can move the PHP floor. Budget a recurring half-day per quarter for upgrade review, and treat version bumps as requiring a runtime check, not just a changelog skim — add "PHP floor changed?" to the upgrade checklist. Keep the adapter boundary so API-level changes are contained; keep the version pinned so runtime-level changes are contained. Maintain a documented fallback: because the package is small, a vendored fork under our namespace is a viable 1–2 day contingency if the maintainer disappears — and a fork also lets us keep 8.1 support if we are ever forced to.

Support. Community-only: GitHub issues, no SLA, no paid support. Internal ownership must be explicit — assign a named engineer as the package owner, and record it in the service catalog. The 8.5 addition is a mild positive for the support story: it shows the maintainer reacts to upstream PHP releases, which is the single best leading indicator that they will react to security issues too. Escalation path is still "fork it," so the fork procedure should be written down before it's needed.

Scaling. Unchanged. Decoding is CPU-bound and reflection-heavy. For low-volume API clients and webhook handlers (hundreds to low thousands per day) it's a non-issue. For batch jobs or high-throughput queues, benchmark first: if a single decode exceeds ~1 ms at our payload sizes, consider caching decoder instances (they're stateless), batching, or generating hydrators. Memory footprint is negligible; the risk is latency under volume, not RAM. Note that a mandatory PHP 8.2+ runtime usually brings a small performance win on its own, so the benchmark numbers from the spike may look slightly better than they would have on 8.1 — record the runtime alongside the results.

Failure modes.

  • Silent data loss: missing JSON keys may leave properties null/uninitialized rather than throwing — the most dangerous mode. Mitigate with strict validation (Laravel validator or JSON Schema) before decoding, plus DTO constructors that reject missing required fields.
  • Deploy-time resolution failure (new/raised): a composer update that pulls 5.1.0 onto a PHP 8.1 host fails at install time, not runtime — usually caught in CI, but it will bite if any long-lived environment (a legacy queue worker image, a sidecar) lags the main app. Detect via the runtime floor audit and by pinning the version.
  • Type coercion surprises: string "123" into int, numeric into string, arrays into single objects — verify and lock behaviour with tests.
  • Nested class resolution: a typo or unimported class in a docblock fails at runtime, not compile time; add a smoke test per DTO.
  • Upstream schema drift: third-party APIs change fields; decoding will tolerate extra keys and silently drop removed ones. Pair with contract tests against recorded fixtures and alert on decode exceptions.
  • Abandonment: covered by the fork contingency, but only if the adapter boundary exists. Downgraded slightly given the demonstrated PHP 8.5 responsiveness.

Ramp-up. Low: a mid-level Laravel developer is productive in half a day. The README covers the core API; the real onboarding cost is our internal conventions (DTO location, adapter usage, strict-validation rule, fixture-test pattern, pinned-version policy). Write a short internal "how we decode JSON" doc and one reference DTO before the second integration ships.

Overall. v5.1.0 is not a breaking change to the library's API, but it is a breaking change to its installability — the PHP floor moved from 8.1 to 8.2 in a minor release. That does not change the recommendation, but it sharpens it: gate on the runtime audit as well as the license, pin the version explicitly, and let the adapter absorb API drift while the pin absorbs platform drift. The PHP 8.5 support is a modestly encouraging maintenance signal. Still a reasonable, low-ceremony tool for a bounded problem — typed hydration of external JSON — provided legal clears the license and we wrap it behind our own interface. It is not a strategic bet: the low opportunity score and single-vendor maintenance argue for containment, not ubiquity. Approve for a scoped pilot pending the runtime audit, spike, and benchmark.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager