laminas/laminas-serializer
Laminas serializer library providing adapters for PHP serialize, JSON, igbinary, and more, plus a configurable factory for serializing and deserializing data in Laminas and Mezzio applications.
Laminas\Serializer\Adapter\AdapterInterface, bound through Laravel’s DI container. No architectural rework required.PSR/Container v2.0.0+ remains the contract; Laravel’s container satisfies it natively.laminas-json has been removed as a dependency; the Json adapter now uses PHP’s native json_encode()/json_decode(). This tightens alignment with Laravel’s own JSON handling (JsonResponse, json_encode in Illuminate\Support\Js/Json), reducing behavioral divergence between the serializer and framework internals.Module class (a laminas-mvc/mezzio artifact) is gone. This has no impact on Laravel, which never consumed it, but it does mean any copy-pasted Laminas module config in docs/tutorials is obsolete.JsonResponse), caching (Illuminate\Cache), queues/jobs payloads, and middleware/event serialization all remain viable targets.Json adapter is now a thin wrapper over native functions, output and performance should be near-identical to Laravel’s native json_encode(). This removes a previous objection to using the adapter on hot paths (previously flagged as a latency risk).laminas-json eliminates a transitive dependency and its version constraints, simplifying composer.json resolution in Laravel projects that already pin JSON-related packages.spatie/array-to-object, nesbot/carbon, laravel/sanctum, etc.PhpSerialize Deprecated Option Removed: Any configuration passing the previously deprecated option (e.g., custom handlers) will now fail or be ignored. Action required in any Laravel config array or service provider that set it.laminas-json Removed: Code that referenced Laminas\Json\Json directly, or that relied on Laminas\Json\Exception\* being thrown from the adapter, must migrate to native JsonException handling. Exception types and error semantics may differ subtly.Module Class Removed: No Laravel impact, but breaks any fork/copy referencing it.^3.3 composer constraint will block the upgrade; composer update will not pull 4.0.0 without a constraint change.laminas-servicemanager v4.0+ remains required (~1MB), but laminas-json is gone. Net vendor size decreases.config/serializer.php, service provider, env-driven options) set the removed PhpSerialize option? This must be audited before upgrading.laminas-json Coupling: Does any first-party code reference Laminas\Json\* classes or catch its exceptions? If so, plan the swap to native JsonException in the same PR.laminas-json-backed adapter? Re-run them against v4 to confirm parity (flags, depth, unicode escaping).^4.0 immediately, or stage via a branch to validate the PhpSerialize and JSON changes independently?AdapterInterface in AppServiceProvider::boot() or a dedicated SerializerServiceProvider.
$this->app->bind(
\Laminas\Serializer\Adapter\AdapterInterface::class,
\Laminas\Serializer\Adapter\Json::class
);
json_encode() for cross-platform cache storage.JsonResource with the Json adapter remains valid, and output parity with native JSON is now stronger.Json for API compatibility, PhpSerialize for database storage. Remove any deprecated PhpSerialize options from configuration.Laminas\Json, PhpSerialize option keys, and any Module class usage.serialize(), json_encode(), custom implementations).composer.json constraint from ^3.3 to ^4.0:
"require": {
"laminas/laminas-serializer": "^4.0"
}
composer update laminas/laminas-serializer and confirm laminas-json is dropped from composer.lock.PhpSerialize option from config arrays:
'adapters' => [
'default' => env('SERIALIZER_ADAPTER', 'json'),
'options' => [
'json' => ['pretty_print' => env('JSON_PRETTY', false)],
// 'php' handlers option removed in v4 — delete if present
],
],
serialize() calls with app(AdapterInterface::class)->serialize($data); retain the UsesSerializer trait helper.Cache, Queue, and Http layers.laminas-json → native JsonException differences.composer.json for any PHP minimum bump; if it rises above 8.1, confirm the project’s PHP version.AdapterInterface directly. The two real code touches are (a) removing the deprecated PhpSerialize option and (b) replacing any direct Laminas\Json references.laminas-json removed. Re-check for conflicts with other Laminas packages (e.g., laminas/laminas-mvc) after the bump.laminas/laminas-serializer:^2.18; the 3.x and 4.x lines are not PHP-8.0-compatible.Laminas\Json usage and deprecated PhpSerialize options.serialize() in non-critical paths (logging, non-sensitive caching).serialize() calls.AdapterInterface.laminas-servicemanager aligned with Laravel’s PSR-11 container updates.laminas-json is no longer a transitive dependency to monitor.PhpSerialize option.JsonException, json_last_error).config/serializer.php; delete any legacy PhpSerialize option keys during the v4 upgrade.PhpSerialize option is still configured. Resolution: remove the key.JsonException instead of Laminas\Json\Exception\*. Resolution: update catch blocks / exception mappings.^3.3 pin prevents 4.0.0 install. Resolution: widen the constraint.laminas-json; no change to autoload overhead of laminas-servicemanager.PhpSerialize option surfacing in the service provider at container build. Mitigation: remove the option; add a config lint step in CI.JsonException propagation instead of Laminas-specific exceptions. Mitigation: standardize exception handling in middleware/validation.composer why-not before the bump.AdapterInterface surface is unchanged; the two migration touchpoints (PhpSerialize option, native JSON exceptions) are small and documented.How can I help you explore Laravel packages today?