zumba/json-serializer
Serialize and unserialize PHP values to JSON (like serialize()), including scalars, arrays, objects, recursion, stdClass extra properties, nested data, and binary. Optional closure support via third party. PHP 7.2+; avoid 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).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.PHP Version Support (Confirmed)
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.| Risk Area | Severity | Mitigation Strategy | Update from 3.2.3 |
|---|---|---|---|
| Breaking Changes | None | No breaking changes in 3.2.4; pin version in composer.json. |
N/A |
| Performance | Medium | Benchmark parent class property access overhead vs. native json_encode(). Focus on large object graphs. |
Updated |
| Complexity Bloat | Low | Restrict to API payloads, legacy migration, and event-driven architectures. | N/A |
| Maintenance Burden | Low | MIT license; fork if upstream stalls. Monitor Opis/Closure v4 stability. | N/A |
| Security | High | New: Enforce strict mode for unserialize(); restrict to whitelisted trusted sources (e.g., internal APIs). Audit cached data (Redis, file cache). |
Updated |
| 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. |
Added |
| Opis/Closure v4 | Low | Monitor for tooling conflicts (Pint, PHPStan). | Added |
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:
How can I help you explore Laravel packages today?