Making API Platform serialization superfast
summary
API Platform swaps Symfony Serializer for a generated JsonEncoder that uses TypeInfo metadata to predict JSON shapes, write directly to a stream and keep memory flat for huge collections. The encoder generates PHP functions once, enabling streaming and tokenized, lazy parsing, and benchmarks show up to 40× faster serialization (10×–15× with an object mapper). Limitation: it cannot change object shape, so use one resource per representation plus an object-mapper for conversions; integration needs a SerializeAndResponseProcessor to stream responses.
AI-written summary · about
chapters (11)
- 0:00Introduction and speaker background
- 1:57What is serialization
- 5:37Symfony serializer fundamentals
- 10:24Understanding metadata in PHP
- 15:55Symfony serializer memory limits
- 17:24Introducing JsonEncoder component
- 23:35Serialization shape limitations
- 24:42Resource design best practices
- 27:43Object mapping with ObjectMapper
- 29:11Performance benchmarks
- 30:21Future developments and conclusion
