<p>While using XDebug and a good IDE can be indispensable to debug your application, sometimes a quick <codeclass="docutils literal notranslate"><spanclass="pre">var_dump()</span></code> is
all you need. CodeIgniter makes that even better by bundling in the excellent <aclass="reference external"href="https://kint-php.github.io/kint/">Kint</a>
the <codeclass="docutils literal notranslate"><spanclass="pre">$useKint</span></code> value in the environment configuration section of the main <strong>index.php</strong> file:</p>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">d()</span></code> method dumps all of the data it knows about the contents passed as the only parameter to the screen, and
<p>This method is identical to <codeclass="docutils literal notranslate"><spanclass="pre">d()</span></code>, except that it also <codeclass="docutils literal notranslate"><spanclass="pre">dies()</span></code> and no further code is executed this request.</p>
<h2><aclass="toc-backref"href="#id4">The Debug Toolbar</a><aclass="headerlink"href="#the-debug-toolbar"title="Permalink to this headline">¶</a></h2>
<p>The Debug Toolbar provides at-a-glance information about the current page request, including benchmark results,
queries you have run, request and response data, and more. This can all prove very useful during development
to help you debug and optimize.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">The Debug Toolbar is still under construction with several planned features not yet implemented.</p>
</div>
<divclass="section"id="enabling-the-toolbar">
<h3><aclass="toc-backref"href="#id5">Enabling the Toolbar</a><aclass="headerlink"href="#enabling-the-toolbar"title="Permalink to this headline">¶</a></h3>
<p>The toolbar is enabled by default in any environment <em>except</em> production. It will be shown whenever the
<p>The toolbar itself is displayed as an <aclass="reference internal"href="../incoming/filters.html"><spanclass="doc">After Filter</span></a>. You can stop it from ever
running by removing it from the <codeclass="docutils literal notranslate"><spanclass="pre">$globals</span></code> property of <strong>app/Config/Filters.php</strong>.</p>
<p>Comment out any collectors that you do not want to show. Add custom Collectors here by providing the fully-qualified
class name. The exact collectors that appear here will affect which tabs are shown, as well as what information is
shown on the Timeline.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">Some tabs, like Database and Logs, will only display when they have content to show. Otherwise, they
are removed to help out on smaller displays.</p>
</div>
<p>The Collectors that ship with CodeIgniter are:</p>
<ulclass="simple">
<li><strong>Timers</strong> collects all of the benchmark data, both by the system and by your application.</li>
<li><strong>Database</strong> Displays a list of queries that all database connections have performed, and their execution time.</li>
<li><strong>Logs</strong> Any information that was logged will be displayed here. In long-running systems, or systems with many items being logged, this can cause memory issues and should be disabled.</li>
<li><strong>Views</strong> Displays render time for views on the timeline, and shows any data passed to the views on a separate tab.</li>
<li><strong>Cache</strong> Will display information about cache hits and misses, and execution times.</li>
<li><strong>Files</strong> displays a list of all files that have been loaded during this request.</li>
<li><strong>Routes</strong> displays information about the current route and all routes defined in the system.</li>
<h3><aclass="toc-backref"href="#id6">Setting Benchmark Points</a><aclass="headerlink"href="#setting-benchmark-points"title="Permalink to this headline">¶</a></h3>
<p>In order for the Profiler to compile and display your benchmark data you must name your mark points using specific syntax.</p>
<p>Please read the information on setting Benchmark points in the <aclass="reference internal"href="benchmark.html"><spanclass="doc">Benchmark Library</span></a> page.</p>
<h3><aclass="toc-backref"href="#id7">Creating Custom Collectors</a><aclass="headerlink"href="#creating-custom-collectors"title="Permalink to this headline">¶</a></h3>
<p>Creating custom collectors is a straightforward task. You create a new class, fully-namespaced so that the autoloader
can locate it, that extends <codeclass="docutils literal notranslate"><spanclass="pre">CodeIgniter\Debug\Toolbar\Collectors\BaseCollector</span></code>. This provides a number of methods
<p><strong>$hasTimeline</strong> should be set to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code> for any Collector that wants to display information in the toolbar’s
timeline. If this is true, you will need to implement the <codeclass="docutils literal notranslate"><spanclass="pre">formatTimelineData()</span></code> method to format and return the
<p><strong>$hasTabContent</strong> should be <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code> if the Collector wants to display its own tab with custom content. If this
is true, you will need to provide a <codeclass="docutils literal notranslate"><spanclass="pre">$title</span></code>, implement the <codeclass="docutils literal notranslate"><spanclass="pre">display()</span></code> method to render out tab’s contents,
and might need to implement the <codeclass="docutils literal notranslate"><spanclass="pre">getTitleDetails()</span></code> method if you want to display additional information just
to the right of the tab content’s title.</p>
<p><strong>$hasVarData</strong> should be <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code> if this Collector wants to add additional data to the <codeclass="docutils literal notranslate"><spanclass="pre">Vars</span></code> tab. If this
is true, you will need to implement the <codeclass="docutils literal notranslate"><spanclass="pre">getVarData()</span></code> method.</p>
<li>Fill in <codeclass="docutils literal notranslate"><spanclass="pre">$title</span></code> with the text displayed as both the toolbar title and the tab header.</li>
<li>Set <codeclass="docutils literal notranslate"><spanclass="pre">$hasTabContent</span></code> to <codeclass="docutils literal notranslate"><spanclass="pre">true</span></code>.</li>
<li>Implement the <codeclass="docutils literal notranslate"><spanclass="pre">display()</span></code> method.</li>
<li>Optionally, implement the <codeclass="docutils literal notranslate"><spanclass="pre">getTitleDetails()</span></code> method.</li>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">display()</span></code> creates the HTML that is displayed within the tab itself. It does not need to worry about
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">getTitleDetails()</span></code> method should return a string that is displayed just to the right of the tab’s title.
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">formatTimelineData()</span></code> method must return an array of arrays formatted in a way that the timeline can use
<spanclass="s1">'name'</span><spanclass="o">=></span><spanclass="s1">''</span><spanclass="p">,</span><spanclass="c1">// Name displayed on the left of the timeline</span>
<spanclass="s1">'component'</span><spanclass="o">=></span><spanclass="s1">''</span><spanclass="p">,</span><spanclass="c1">// Name of the Component listed in the middle of timeline</span>
<spanclass="s1">'start'</span><spanclass="o">=></span><spanclass="mf">0.00</span><spanclass="p">,</span><spanclass="c1">// start time, like microtime(true)</span>
<spanclass="s1">'duration'</span><spanclass="o">=></span><spanclass="mf">0.00</span><spanclass="c1">// duration, like mircrotime(true) - microtime(true)</span>
<spanclass="p">];</span>
</pre></div>
</div>
</div>
<divclass="section"id="providing-vars">
<h4>Providing Vars<aclass="headerlink"href="#providing-vars"title="Permalink to this headline">¶</a></h4>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">getVarData()</span></code> method should return an array containing arrays of key/value pairs to display. The name of the
outer array’s key is the name of the section on the Vars tab:</p>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.