In Symfony (or plain PHP) projects Doctrine allows you to focus on domain concepts and implement application use cases quickly, letting the library generate both write and read SQL queries.

One of the mechanisms used by Doctrine is lazy loading. When we access, for the first time, an association present in one of our entities, Doctrine performs, behind the scenes, the db query necessary to retrieve the data and constructs the objects referred by the association.

This approach involves a large number of queries, especially for complex domains, where entities have many associations. …


In my previous post we saw, in the context of a REST application created with Symfony and PHP8, how to obtain a DTO as a parameter of an action, deserializing the json content of the request body with the Symfony serializer component and exploiting the information available in the URI using a PHP8 attribute.

The DTO thus obtained, however, contains only primitive data, so if in the request there are references to objects of our domain, these will remain as such and will not be converted into the objects themselves.

To achieve this we could use a de/serialization library, such…


Version 8 of PHP was released just over 2 months ago, and among the most important changes there is the introduction of attributes, which will allow you to create with native syntax what has been achieved up to now with PHPDoc and Doctrine annotations.

The Symfony framework makes extensive use of them, for example to specify routing directly in controllers and validation rules in entities. Version 5.2 already supports PHP8 attributes in both cases.

Value Resolvers

Symfony Value Resolvers are a mechanism that allows, for example, to obtain as arguments of an action:

  • services registered in the application container
  • session object or…

Antonio Turdo

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store