nfaiz / dbtoolbar
CodeIgniter 4 Database Debug Toolbar Query Highlighter.
Installs: 8 852
Dependents: 2
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nfaiz/dbtoolbar
Requires
- codeigniter4/framework: ^4.1.7
- scrivo/highlight.php: ^9.18
README
Query Highlighter
Description
CodeIgniter 4 Database Debug Toolbar Query Highlighter.
Table of contents
- Requirement
- Installation
- Configuration (Optional)
- ScreenShot
- Credit
Requirement
Installation
Install library via composer:
composer require nfaiz/dbtoolbar
Query Highlighter is located at DbQueries tab (Debug Toolbar)
Configuration
Remove Default Database Tab
- Open and comment
Database::classfrom$collectorsproperty inapp/Config/Toolbar.php.
public array $collectors = [ // Database::class, ];
- Open and comment
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');inapp/Config/Events.php.
if (CI_DEBUG && ! is_cli()) { // Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect'); Services::toolbar()->respond(); }
Modify Settings.
Open and add properties below in app/Config/Toolbar.php accordingly.
/** * ------------------------------------------------------------- * 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;
Custom Syntax Highlighter view.
Open app/Config/Toolbar.php and add/edit template view file using $dbToolbarTpl property.
You can create your own view and you change it accordingly. For Example public $dbToolbarTpl = dbtoolbar/database;
Views/dbtoolbar/database.php.
{! 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>
Screenshot
Default Database Toolbar
- Light
- Dark
Using DbToolbar
- Light
- Dark
Credit
- Inspired by this pull request



