API Platform: Normalizer vs Denormalizer
12 December 2023 (Updated 12 December 2023)
On this page
Normalizer
Converts PHP entities (e.g., Doctrine entity or a DTO) into a PHP array which is then encoded into another format like JSON.
Typical use cases:
- Hide fields if the user doesn’t have the right permissions.
- Add extra fields to the response.
Denormalizer
Converts a PHP array into a PHP object (e.g., Doctrine entity).
Typical use cases:
- Set an entity’s user to the current user (e.g.,
$article->setUser($this->security->getUser()
. - Decode a base-64 encoded string in the request payload to upload a file to S3.
Tagged:
API Platform
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment