How to use Symfony Vardumper to avoid displaying relationships
Is is possible that even when the relationships are there avoiding to display those relationships? with a limiter or something?
Thanks you. Been searching for this for a while
How to use Symfony Vardumper to avoid displaying relationships
Is is possible that even when the relationships are there avoiding to display those relationships? with a limiter or something?
Thanks you. Been searching for this for a while
You can implement a __debugInfo
method on your objects returning an array with only the keys you want to display or (if you don’t own the code of the objects you want to dump) you have to create a custom object caster and register it on the var_dumper.cloner
service.
In this second case, the symfony debug-bundle must be registered, then you can create your own caster function.
In the caster function you can even customize the class name displayed for your object using the $stub
(3rd) parameter.
use Symfony\Component\VarDumper\Cloner\Stub;
Ex:
<?php
function obj_caster($object, $array, Stub $stub, $isNested, $filter)
{
// ... populate $array or unset some keys ...
return $array;
}
See the documentation here: https://symfony.com/doc/current/components/var_dumper/advanced.html