PHP code example of nfaiz / dbtoolbar

1. Go to this page and download the library: Download nfaiz/dbtoolbar library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nfaiz / dbtoolbar example snippets



public array $collectors = [
    // Database::class,
];

if (CI_DEBUG && ! is_cli()) {
  // Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
  Services::toolbar()->respond();
}


/**
 * -------------------------------------------------------------
 * Disable DbToolbar query Highlighter
 * -------------------------------------------------------------
 * 
 * To disable DbToolbar query highlighter, change value to true
 *
 * @var bool
 */
public bool $dbToolbarDisable = false;

/**
 * -------------------------------------------------------------
 * DbToolbar Theme
 * -------------------------------------------------------------
 * 
 * Configuration for light and dark mode SQL Syntax Highlighter.
 * Refer https://github.com/scrivo/highlight.php/tree/master/src/Highlight/styles or
 * use \HighlightUtilities\getAvailableStyleSheets(); for available stylesheets.
 *
 * @var array
 */
public array $dbToolbarTheme = [
    'light' => 'atom-one-light',
    'dark'  => 'atom-one-dark'
];

/**
 * -------------------------------------------------------------
 * DbToolbar View
 * -------------------------------------------------------------
 * 
 * To override DbToolbar SQL Syntax Highlighter view.
 *
 * @var array
 */
public string $dbToolbarTpl = 'Nfaiz\DbToolbar\Views\database.tpl';

/**
 * -------------------------------------------------------------
 * Bottom Margin Between Diplayed Query in Toolbar
 * -------------------------------------------------------------
 * 
 * Value in px
 * 
 * @var int
 */
public int $dbToolbarMarginBottom = 4;

/**
 * -------------------------------------------------------------
 * Log Queries
 * -------------------------------------------------------------
 *
 * Please set threshold to minimum 7 at app/Config/Logger.php
 * Logs can be found at ROOTPATH/writable/logs
 *
 * @var boolean
 */
public bool $dbToolbarLogger = false;


{! hlstyle !}
<table>
    <thead>
        <tr>
            <th class="debug-bar-width6r">Time</th>
            <th>Query String</th>
        </tr>
    </thead>
    <tbody>
    {queries}
        <tr class="{class}" title="{hover}" data-toggle="{qid}-trace">
            <td class="narrow" style="vertical-align: top;">{duration}</td>
            <td><u>{trace-file}</u>{! sql !}</td>
        </tr>
        <tr class="muted debug-bar-ndisplay" id="{qid}-trace">
            <td></td>
            <td>
            {trace}
                {index}<strong>{file}</strong><br/>
                {function}<br/><br/>
            {/trace}
            </td>
        </tr>
    {/queries}
    </tbody>
</table>