zumba/json-serializer
A PHP library that serializes variables and objects to JSON and restores them, including binary data, nested objects, recursion, and closures. Requires PHP 7.2+; never unserialize untrusted input.
Core Use Case Alignment (Confirmed)
HasAuditLog or SoftDeletes with private/protected parent properties). Eliminates manual accessor overrides, aligning with Laravel’s composition-over-inheritance patterns while accommodating legacy codebases.protected Carbon\Carbon $created_at). Prevents fatal errors during serialization/deserialization, reducing friction for modern Laravel APIs and event-driven architectures (e.g., Horizon jobs).SECURITY.md introduces unserialize input validation, addressing a critical gap in Laravel’s native tools. Complements Illuminate\Validation and GraphQL/API payload use cases where serialized data is consumed from untrusted sources (e.g., microservices or legacy systems).SplObjectStorage::contains()/attach() and ReflectionProperty::setAccessible() deprecations. This is architecturally neutral but strategically material — it removes a known blocker for teams sequencing a PHP 8.5 / Laravel 12+ upgrade, and it means the package’s reflection internals are being tracked against the PHP runtime roadmap rather than lagging it.Laravel Ecosystem Synergy (Expanded)
App\Models\User extending App\Models\Concerns\HasMetadata). Reduces reliance on custom JsonSerializable implementations.Redis::remember() with typed properties).Alternatives Revisited (Unchanged)
Laravel Compatibility (Confirmed)
strict_types=1 and typed Eloquent fields (e.g., protected int $status).getAttribute() overrides for private parent properties, reducing technical debt in legacy codebases.SECURITY.md aligns with Laravel’s input validation best practices (e.g., Illuminate\Validation\Rules\ValidatedData).App\Exceptions\Handler if both use json_encode(). Mitigation: Use middleware only for API routes and avoid overriding Handler.3.2.4 for legacy compatibility is exposed to a fatal ReflectionProperty::isInitialized() error. Constraint must be ^3.2.5 or tighter, not ^3.2.PHP Version Support (Updated)
Testing Overhead (Updated)
BaseModel with private fields (e.g., App\Models\User → App\Models\Concerns\HasAuditLog).protected ?string $metadata).unserialize() usage in request parsing and cached data (e.g., Redis::remember()).json_encode() for 10K+ objects with typed properties.E_ALL on PHP 8.5 and fail on deprecations — specifically SplObjectStorage and ReflectionProperty::setAccessible() paths, which are runtime-sensitive and were only caught upstream after release.| Risk Area | Severity | Mitigation Strategy | Update from 3.2.4 |
|---|---|---|---|
| Breaking Changes | None | 3.2.5 is a patch release; no API changes. Pin ^3.2.5 in composer.json — do not allow 3.2.4. |
Updated (pin floor) |
| Release Quality / Regression | Medium | 3.2.4 introduced a fatal error on PHP < 7.4 (ReflectionProperty::isInitialized()), repaired in 3.2.5. Treat patch releases as reviewable: enable Dependabot/Renovate with a staging soak before merge; require CI on the floor and ceiling of our PHP matrix. |
New |
| Performance | Medium | Benchmark parent class property access overhead vs. native json_encode(). Focus on large object graphs. 3.2.5 changes reflection call paths (deprecation fixes) — re-run benchmarks, do not assume parity with 3.2.4. |
Updated (re-benchmark) |
| Complexity Bloat | Low | Restrict to API payloads, legacy migration, and event-driven architectures. | N/A |
| Maintenance Burden | Low | MIT license; fork if upstream stalls. Upstream responsiveness is evidenced (3 issues closed, community PR merged within the 3.2.5 cycle). | Upgraded (signal positive) |
| Security | High | Unchanged and still the dominant risk. Enforce strict mode for unserialize(); restrict to whitelisted trusted sources (e.g., internal APIs). Audit cached data (Redis, file cache) and event payloads. 3.2.5 does not alter the security posture. |
Unchanged |
| Typed Property Support | Low | Test with PHP 8.0+ Eloquent models and nullable types. | N/A |
| Parent Class Access | Medium | Validate no conflicts with Laravel’s getAttribute(). Test with deep inheritance chains. |
N/A |
| Opis/Closure v4 | Low | Monitor for tooling conflicts (Pint, PHPStan) on PHP 8.5. | Updated (8.5) |
| PHP Version Drift | Low | Matrix verified 7.2–8.5 in CI each release. Re-check matrix coverage per release; floor support can silently regress (as 3.2.4 demonstrated). | Updated |
| PHP 8.5 Deprecations | Low | Resolved in 3.2.5 (SplObjectStorage, ReflectionProperty::setAccessible()). Removes a known Laravel 12+/PHP 8.5 upgrade blocker. |
Resolved |
App\Models\User extends App\Models\BaseModel with private $apiToken, will the serializer bypass getAttribute('api_token')?getApiTokenAttribute()).json_encode() for 10K Eloquent models with typed properties.unserialize() be secured in Laravel?
allowed_classes config only for internal APIs; avoid for public-facing endpoints.JsonSerializable for private parent properties?
protected/private fields in inheritance chains (e.g., User → BaseModel → Authenticatable).Redis::remember() with typed properties).Opis/Closure v4 affect Laravel’s existing tooling?
illuminate/support, laravel/framework, or Laravel Forge/Envoyer.php artisan optimize and composer validate post-integration.App\Exceptions\Handler?
Handler and middleware use json_encode().Handler::render().toArray()/toJson() for models with:
App\Models\Concerns\HasAuditLog).protected ?string $metadata).unserialize() with strict validation for:
PATCH /users with complex updates).serialize()-based storage to JSON with:
json_encode() drops private parent state."zumba/json-serializer": "^3.2.5" — explicitly exclude 3.2.4 on any PHP < 7.4 host. Lock file review required.toArray().unserialize() inputs completes.3.2.4 on PHP < 7.4 (fatal). Not a code-level incompatibility with our stack, but a version-pinning hazard.^3.2.5; enable automated dependency PRs with staging soak.unserialize() call sites; enforce whitelisting.unserialize() call sites must have a named owner and a documented allowlist. 3.2.5 does not change this; the risk is unchanged from 3.2.4.toArray() is preferred.| Failure Mode | Trigger | Impact | Detection / Mitigation |
|---|---|---|---|
| Fatal on legacy PHP | Running 3.2.4 on PHP 7.2/7.3 | Hard 500s / worker crashes on serialization | Pin ^3.2.5; floor CI job; composer.lock audit |
| PHP 8.5 deprecation noise | Pre-3.2.5 on 8.5 (SplObjectStorage, setAccessible()) |
Log flood, future hard failures | Upgrade to 3.2.5; fail CI on deprecations |
| Unsafe deserialization | Untrusted input reaching unserialize() |
Object injection / RCE-class exposure | strict mode, allowed_classes allowlist, endpoint restriction |
| Silent state loss | Private parent properties dropped by native path | Missing fields in API responses / jobs | Golden-file serialization tests on inheritance chains |
| Accessor bypass | Serializer reads raw property, skipping getAttribute() |
Business logic (mutators, encryption casts) skipped | Test with overridden accessors; review casts on serialized models |
| Exception handler collision | Middleware and App\Exceptions\Handler both encoding JSON |
Malformed error responses | Restrict middleware to API routes; don't override Handler::render() |
| Payload bloat | Large graphs serialized into Redis/queues | Memory pressure, latency | Size ceilings, sampling, monitoring |
unserialize() inputs is 1–2 days of focused review and should not be delegated to the same half-day integration window.^3.2.5. 3.2.5 is a net-positive, non-breaking maintenance release that widens verified runtime coverage (7.2–8.5), clears the PHP 8.5 upgrade blocker, and repairs a regression that 3.2.4 introduced. It does not change the security risk profile, which remains the single item requiring active governance.How can I help you explore Laravel packages today?