lara-igniter / laraigniter-debugbar
PHP Debugbar integration for the Laraigniter framework.
Package info
github.com/lara-igniter/laraigniter-debugbar
pkg:composer/lara-igniter/laraigniter-debugbar
Requires
- php: ^7.4|^8.0
- lara-igniter/framework: ^1.0
- maximebf/debugbar: ^1.23
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
PHP Debugbar integration for Laraigniter (CodeIgniter 3 + Elegant providers).
Built on maximebf/debugbar v1 with a Laraigniter theme, collectors, and automatic HTML injection.
Use only in development. Do not enable the debugbar on publicly accessible production sites — stored request data and collectors can expose sensitive information.
Requirements
- PHP ^7.4
lara-igniter/framework^1.0maximebf/debugbar^1.23 (installed automatically)
Installation
Install as a development dependency:
composer require lara-igniter/laraigniter-debugbar --dev
1. Register the service provider
In config/hooks.php, add the provider to the providers array:
Laraigniter\Debugbar\DebugbarServiceProvider::class,
Optionally register the facade alias in the same file:
'Debugbar' => Laraigniter\Debugbar\Facades\Debugbar::class,
2. Publish assets (required)
Core debugbar JS/CSS and the Laraigniter theme are served from public/build/assets/php-debugbar/. Publish them once after install (and again after upgrades or theme edits):
php artisan vendor:publish --tag=debugbar-assets
After changing theme files in the package resources/ folder, or after upgrading maximebf/debugbar:
php artisan vendor:publish --tag=debugbar-assets --force
Published layout:
| Source | Published to |
|---|---|
vendor/maximebf/debugbar (JS, CSS, widgets, jQuery, Font Awesome, Highlight.js) |
public/build/assets/php-debugbar/ |
laraigniter-debugbar.css, laraigniter-icons.css, laraigniter-widgets.js |
same directory |
3. Publish config (optional)
Configuration is loaded from the package by default. To override settings in your app:
php artisan vendor:publish --tag=debugbar-config
This creates config/debugbar.php.
Enabling / disabling
The debugbar is enabled when:
APP_DEBUG=true, and- the environment is not
productionortesting, and DEBUGBAR_ENABLEDis not set tofalse
Override explicitly in .env:
DEBUGBAR_ENABLED=true # or DEBUGBAR_ENABLED=false
For local edge cases (e.g. forcing enable outside normal rules):
DEBUGBAR_FORCE_ALLOW_ENABLE=true
Usage
Automatic injection
On HTML responses, the debugbar is injected before </body> when debugbar.inject is true (default). No layout changes are required beyond having jQuery available on the page (see jQuery below).
Open-handler routes are registered automatically under the _debugbar prefix (default). You do not add debugbar routes to routes/web.php.
Logging messages
Via the debugbar() helper (returns the debugbar instance, or null when unavailable — check before calling when debugbar may be off):
debugbar()->info('Checkout started'); debugbar()->info(['cart_id' => 1]); debugbar()->warning('Slow query detected'); debugbar()->addMessage('Custom label', 'notice');
Same via facade:
use Laraigniter\Debugbar\Facades\Debugbar; Debugbar::info('Checkout started'); Debugbar::warning('Slow query detected');
Shorthand when you only need a single message and debugbar may be off:
debugbar_message('Something happened', 'info');
Via the in-memory console logger (messages also appear in the Messages tab):
app('console')->info('Logged from console'); app('console')->warning('Watch out'); app('console')->exception(new Exception('test'));
Timing
When the time collector is enabled:
debugbar()->startMeasure('render', 'Time for rendering'); // … debugbar()->stopMeasure('render');
Or via facade:
Debugbar::startMeasure('render', 'Time for rendering'); Debugbar::stopMeasure('render');
Exceptions
try { throw new Exception('Something failed'); } catch (Exception $e) { debugbar()->addThrowable($e); }
AJAX requests
When DEBUGBAR_CAPTURE_AJAX=true (default), debugbar data for AJAX requests is sent in response headers. The UI can auto-open or show an AJAX tab depending on:
DEBUGBAR_AJAX_HANDLER_AUTO_SHOW=true DEBUGBAR_AJAX_HANDLER_ENABLE_TAB=true
Enabling / disabling at runtime
You can enable or disable the debugbar during a request:
use Laraigniter\Debugbar\Facades\Debugbar; Debugbar::enable(); Debugbar::disable();
Same via the debugbar() helper:
if ($bar = debugbar()) { $bar->enable(); $bar->disable(); }
Note: Once enabled, collectors are registered and may add overhead. Prefer keeping
DEBUGBAR_ENABLED=falsein config and enabling only when needed.By default the debugbar only runs when
APP_DEBUG=trueand the environment is notproductionortesting. To allow runtime enable in stricter environments, setDEBUGBAR_FORCE_ALLOW_ENABLE=true— this does not auto-enable the debugbar; it lets the service provider register the instance so you can callenable()later.
Collectors
Toggle each collector with DEBUGBAR_COLLECTORS_* env vars or config/debugbar.php → collectors.
| Collector | Default | What it shows |
|---|---|---|
request |
on | Request tab (headers, query, body, controller) and route indicator on the bar |
exceptions |
on | Captured exceptions |
phpinfo |
on | PHP configuration (phpinfo) |
messages |
on | Custom messages, console logger output |
time |
on | Request duration and timeline (Booting, Application, Routing, Controller, Preparing Response) |
memory |
on | Peak memory usage |
laraigniter |
on | Laraigniter version indicator and environment tooltip |
views |
on | Blade views rendered (optional view data) |
route |
on | Registered routes and the matched route |
logs |
off | Tail of the app log file (config.log_path + config.log_file) |
db |
on | SQL queries (bindings, optional backtrace/timeline) |
mail |
on | Swift messages sent via app('mailer') |
auth |
off | Ion Auth guards (user by default) with name + full user payload |
gate |
on | Policy / gate authorization checks |
jobs |
on | Queue jobs dispatched during the request |
cache |
on | Cache hits/misses and optional timeline |
config |
on | Loaded config file sections (sensitive keys can be masked) |
session |
off | Session data |
files |
off | PHP files included during the request |
Collector options
# Database DEBUGBAR_OPTIONS_DB_WITH_PARAMS=true DEBUGBAR_OPTIONS_DB_BACKTRACE=true DEBUGBAR_OPTIONS_DB_TIMELINE=false # Auth DEBUGBAR_OPTIONS_AUTH_SHOW_NAME=true # Views DEBUGBAR_OPTIONS_VIEWS_TIMELINE=true DEBUGBAR_OPTIONS_VIEWS_TIMELINE_DURATION=false DEBUGBAR_OPTIONS_VIEWS_DATA=false # Gate DEBUGBAR_OPTIONS_GATE_TRACE=false # Cache DEBUGBAR_OPTIONS_CACHE_TIMELINE=true DEBUGBAR_OPTIONS_CACHE_VALUES=false # Mail DEBUGBAR_OPTIONS_MAIL_SHOW_BODY=true # Logs (optional custom log file path) DEBUGBAR_OPTIONS_LOGS_FILE=
Mask sensitive keys in config/debugbar.php under options.request.masked, options.session.masked, and options.config.masked.
jQuery
The debugbar UI expects jQuery. Strategy is controlled by DEBUGBAR_JQUERY:
| Value | Behaviour |
|---|---|
auto (default) |
Use page jQuery if present; otherwise load bundled jQuery synchronously |
app |
Require page jQuery (e.g. from app.js); error in console if missing |
bundled |
Always load php-debugbar’s jQuery with noConflict(true) |
DEBUGBAR_JQUERY=auto
Font Awesome and Highlight.js vendor assets are included by default (DEBUGBAR_INCLUDE_VENDORS=true). Set to false if your layout already loads them, or 'js' / 'css' to include only one.
Storage & open handler
Previous requests are stored on disk (for the open-handler UI) when storage is enabled:
DEBUGBAR_STORAGE_ENABLED=true DEBUGBAR_STORAGE_PATH= # default: storage/debugbar DEBUGBAR_OPEN_STORAGE= # optional: open storage on each request DEBUGBAR_ROUTE_PREFIX=_debugbar
Clear stored requests:
php artisan debugbar:clear
Open-handler URL pattern: /{DEBUGBAR_ROUTE_PREFIX}/open (default: /_debugbar/open). Access is blocked when debugbar cannot be enabled (same rules as above).
Theme & assets
Theme sources ship in the package:
| File | Purpose |
|---|---|
resources/laraigniter-debugbar.css |
Main theme (Laraigniter accent #dd4814) and logo |
resources/laraigniter-icons.css |
Icon masks for debugbar tabs |
resources/laraigniter-widgets.js |
Laraigniter widgets, indicators, settings tab, responsive tabs |
Disable custom theme CSS (core debugbar styling only):
DEBUGBAR_THEME_ENABLED=false
UI preferences (defaults; users can override per browser in the debugbar Settings tab):
DEBUGBAR_THEME=light # light, dark, or auto DEBUGBAR_HIDE_EMPTY_TABS=true DEBUGBAR_OPEN_BTN_POSITION=bottomLeft
Disable asset or script injection entirely (advanced — you must render assets yourself):
DEBUGBAR_DISPLAY_ASSETS=false DEBUGBAR_DISPLAY_JAVASCRIPT=false DEBUGBAR_INJECT=false
Artisan commands
| Command | Description |
|---|---|
php artisan vendor:publish --tag=debugbar-assets |
Publish JS/CSS to public/build/assets/php-debugbar/ |
php artisan vendor:publish --tag=debugbar-assets --force |
Overwrite published assets |
php artisan vendor:publish --tag=debugbar-config |
Publish config/debugbar.php |
php artisan debugbar:clear |
Delete stored open-handler request files |
Environment reference
# Enable / disable DEBUGBAR_ENABLED= DEBUGBAR_FORCE_ALLOW_ENABLE=false # Collectors (true/false) DEBUGBAR_COLLECTORS_REQUEST=true DEBUGBAR_COLLECTORS_EXCEPTIONS=true DEBUGBAR_COLLECTORS_PHPINFO=true DEBUGBAR_COLLECTORS_MESSAGES=true DEBUGBAR_COLLECTORS_TIME=true DEBUGBAR_COLLECTORS_MEMORY=true DEBUGBAR_COLLECTORS_LARAIGNITER=true DEBUGBAR_COLLECTORS_VIEWS=true DEBUGBAR_COLLECTORS_ROUTE=true DEBUGBAR_COLLECTORS_LOGS=false DEBUGBAR_COLLECTORS_DB=true DEBUGBAR_COLLECTORS_MAIL=true DEBUGBAR_COLLECTORS_AUTH=false DEBUGBAR_COLLECTORS_GATE=true DEBUGBAR_COLLECTORS_JOBS=true DEBUGBAR_COLLECTORS_CACHE=true DEBUGBAR_COLLECTORS_CONFIG=true DEBUGBAR_COLLECTORS_SESSION=false DEBUGBAR_COLLECTORS_FILES=false # Rendering DEBUGBAR_THEME_ENABLED=true DEBUGBAR_THEME=light DEBUGBAR_HIDE_EMPTY_TABS=true DEBUGBAR_OPEN_BTN_POSITION=bottomLeft DEBUGBAR_INCLUDE_VENDORS=true DEBUGBAR_JQUERY=auto DEBUGBAR_INJECT=true DEBUGBAR_DISPLAY_ASSETS=true DEBUGBAR_DISPLAY_JAVASCRIPT=true DEBUGBAR_CAPTURE_AJAX=true DEBUGBAR_AJAX_HANDLER_AUTO_SHOW=true DEBUGBAR_AJAX_HANDLER_ENABLE_TAB=true # Storage & routes DEBUGBAR_STORAGE_ENABLED=true DEBUGBAR_STORAGE_DRIVER=file DEBUGBAR_STORAGE_PATH= DEBUGBAR_OPEN_STORAGE= DEBUGBAR_ROUTE_PREFIX=_debugbar DEBUGBAR_ROUTE_DOMAIN= # Collector options DEBUGBAR_OPTIONS_DB_WITH_PARAMS=true DEBUGBAR_OPTIONS_DB_BACKTRACE=true DEBUGBAR_OPTIONS_DB_TIMELINE=false DEBUGBAR_OPTIONS_AUTH_SHOW_NAME=true DEBUGBAR_OPTIONS_VIEWS_TIMELINE=true DEBUGBAR_OPTIONS_VIEWS_TIMELINE_DURATION=false DEBUGBAR_OPTIONS_VIEWS_DATA=false DEBUGBAR_OPTIONS_GATE_TRACE=false DEBUGBAR_OPTIONS_CACHE_TIMELINE=true DEBUGBAR_OPTIONS_CACHE_VALUES=false DEBUGBAR_OPTIONS_MAIL_SHOW_BODY=true DEBUGBAR_OPTIONS_LOGS_FILE= # Misc DEBUGBAR_EDITOR=phpstorm DEBUGBAR_DEBUG_BACKTRACE_LIMIT=50
Excluding routes
URLs excluded from debugbar injection/collection are configured in config/debugbar.php:
'except' => [ '_debugbar*', ],
License
MIT — see LICENSE.md.