I want to print entities in PHP for debug purposes with print_r()
or var_dump()
. The entities are loaded via doctrine/symfony from the database and some of them have a lot of
attributes attached. Example:
file
- id
- name
- extension
- fileGroups
- ...
fileGroups is a list of objects of another entity:
fileGroup
- id
- name
- client
- ...
Client is a another entity ... and so forth.
Now when I execute print_r($file)
, I would like to have only the first list of attributes printed and not the ones below in the hierarchy (because that causes a lazy loading and a memory error in many cases and I'm not interested in that data in the first place).
Is there a possibility to tell PHP to only print certain attribute hierarchies (like only first hierarchy or first and second)? Or is there a way to tell doctrine to not load attributes (maybe with a parameter), if they are printed via PHP?