Reputation: 10143
In the previous question, I asked for an alternative implementation of var_dump that allowed limiting the output of the depth of nested arrays.
Abhishek answered the question. But that function works only on nested arrays. It does't work on object graphs.
How can a var_dump
implementation work on object graphs and limit the output of the depth of nested objects?
Upvotes: 2
Views: 7896
Reputation: 1091
try dump_r.php (php 5.3+).
you can specify the depth to which you want the dump unfolded to and can interactively unfold more later. It will not actually limit the depth of the actual dump though, so if it's needed for performance reasons, it likely won't help in that department. Also, it's in HTML, I will probably add a text-only dump option in the future.
demo: http://o-0.me/dump_r/
repo: https://github.com/leeoniya/dump_r.php
also installable via Composer
require: "leeoniya/dump-r": "dev-master"
https://packagist.org/packages/leeoniya/dump-r
Upvotes: 0
Reputation: 19437
Check out some of the comments under the var_dump
function info at php.net - http://php.net/manual/en/function.var-dump.php - They provide depth level controls for var_dump
as well as few other goodies.
Upvotes: 1
Reputation: 522523
By far the easiest solution is to install the xdebug extension (which is a good idea anyway). It overrides var_dump
with a version which limits output to a configurable depth.
Upvotes: 3