Kint https://blog.werk21.de/en en Dealing with *DEPTH TOO GREAT* in Kint https://blog.werk21.de/en/2017/12/13/dealing-depth-too-great-kint <span>Dealing with *DEPTH TOO GREAT* in Kint</span> <span><span lang="" about="/en/user/8" typeof="schema:Person" property="schema:name" datatype="">patrick</span></span> <span>Wed, 12/13/2017 - 08:58</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>If you use <a href="https://drupal.org/project/devel">Devel</a>'s <span class="geshifilter"><code class="php geshifilter-php">dpm<span style="color: #009900;">(</span><span style="color: #009900;">)</span></code></span> with <a href="https://github.com/kint-php/kint">Kint</a> for debugging in Drupal 8, chances are you already encountered the message <span class="geshifilter"><code class="php geshifilter-php"><span style="color: #339933;">*</span>DEPTH TOO GREAT<span style="color: #339933;">*</span></code></span> when clicking through a deeply nested object.</p> <p>There is a reason for that: Performance. Always rendering all levels of a deeply nested object might result in either your server or your browser to run out of resources and fail. That's why there is a maximum number of levels to show. It's usually at <span class="geshifilter"><code class="php geshifilter-php"><span style="color: #cc66cc;">7</span></code></span> levels.</p> <p>If you need to inspect something that is nested further below, the best thing to do is to limit the <span class="geshifilter"><code class="php geshifilter-php">dpm<span style="color: #009900;">(</span><span style="color: #009900;">)</span></code></span> to a more explicit part of the nested variable. But sometimes you can't or don't want to do that. In those cases, you can increase the maximum levels by placing</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">kint_require<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> \Kint<span style="color: #339933;">::</span><span style="color: #000088;">$maxLevels</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span></pre></div> <p>somewhere above your <span class="geshifilter"><code class="php geshifilter-php">dpm<span style="color: #009900;">(</span><span style="color: #009900;">)</span></code></span> call. <span class="geshifilter"><code class="php geshifilter-php"><span style="color: #000088;">$maxLevels</span></code></span> is of course the maximum number of levels you want to see. If you know what you're doing, you could even use</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">\Kint<span style="color: #339933;">::</span><span style="color: #000088;">$maxLevels</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></pre></div> <p>to remove the limit entirely. Use at your own risk.</p> </div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/drupal-8" class="label label-default" hreflang="de">Drupal 8</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/devel" class="label label-default" hreflang="de">Devel</a> <a href="/en/tags/kint" class="label label-default" hreflang="en">Kint</a> <a href="/en/tags/dpm" class="label label-default" hreflang="en">dpm</a> </div> Wed, 13 Dec 2017 07:58:54 +0000 patrick 129 at https://blog.werk21.de