Printing only the first level attributes in the hierarchy of a variable in PHP

QuestionsPrinting only the first level attributes in the hierarchy of a variable in PHP
Jehal Desai Staff asked 4 years ago

I want to print entities in PHP for debug purposes with or . The entities are loaded via doctrine/symfony from the database and some of them have a lot of
attributes attached. Example:

fileGroups is a list of objects of another entity:

Client is a another entity … and so forth.
Now when I execute , 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?


View on Stack Overflow