symfony/json-streamer
Stream JSON efficiently with Symfony JsonStreamer. Read and write large JSON structures incrementally from streams to reduce memory usage, with powerful helpers for streaming serialization/deserialization and handling big payloads in real time.
StreamedResponse, Illuminate\Contracts\Serializer\Serializer, and queue-based workflows.StreamedResponse, Serializer contracts) without tight coupling, preserving Laravel’s flexibility.json_encode() remains sufficient).composer require symfony/json-streamer:^8.1
return new StreamedResponse(function () {
$streamer = new JsonStreamer();
$streamer->write($largeDataset);
}, 200, ['Content-Type' => 'application/json']);
Illuminate\Support\Collection, Psr\HttpMessage, and Eloquent JSONB fields.include_null_properties).json_encode() for your payloads.StreamedResponse compatibility unchanged.Illuminate\Contracts\Serializer\Serializer as before.Psr\Http\Message.| Phase | Action | Tools/Libraries | Risk |
|---|---|---|---|
| Assessment | Updated: Benchmark v8.1.0-BETA3 against v8.0.8 for edge-case stability. | Blackfire, Laravel Debugbar | Low |
| Pilot | Unchanged: Replace a high-volume JSON endpoint with StreamedResponse. |
symfony/json-streamer:^8.1, StreamedResponse |
Medium (feature parity testing) |
| Core Integration | Unchanged: Extend App\Services\Serializer. |
Illuminate\Contracts\Serializer\Serializer |
High (breaking changes if misconfigured) |
| Queue Processing | Unchanged: Migrate background jobs. | busy:queue, laravel-queue |
Low |
| Monitoring | Updated: Add New Relic/Blackfire to track memory/CPU in v8.1.0-BETA3. | APM tools | Low |
symfony/serializer (use Laravel’s Serializer interface).json_encode() for large payloads (e.g., reports).^8.1 in composer.json for early access to hardenings.JsonException handling (e.g., in a JsonStreamerService).JsonStreamer with Laravel’s logging.How can I help you explore Laravel packages today?