- How do I install Laravel Debugbar without affecting production performance?
- Add it as a dev dependency via `composer require barryvdh/laravel-debugbar --dev`. Publish the config with `php artisan vendor:publish --tag=debugbar-config`, then disable collectors like `db` or `events` in `config/debugbar.php` to minimize overhead. Use middleware to enable it only in local or trusted IPs.
- Can I use Laravel Debugbar with Laravel 10.x or only older versions?
- The package supports Laravel 8.x through 10.x. Check the [GitHub releases](https://github.com/fruitcake/laravel-debugbar/releases) for the latest compatibility notes. If using Laravel 10, ensure your PHP version is 8.0+ and test collectors like `livewire` or `pennant` separately, as they may require additional packages.
- What’s the best way to enable Debugbar only for specific routes or IPs?
- Use middleware to conditionally enable Debugbar. For example, create `app/Http/Middleware/EnableDebugbar.php` and check `app()->environment('local')` or `$request->ip()`. This avoids exposing debug data in production or unauthorized access. Disable storage (`debugbar.storage.open = false`) in `config/debugbar.php` for extra security.
- Does Laravel Debugbar slow down my application in development?
- Yes, enabled collectors (e.g., DB queries, logs) add latency. Mitigate this by disabling unnecessary collectors in `config/debugbar.php` and using `debugbar()->enable()` only when needed. Test performance with tools like Laravel Debugbar’s `hard_limit` and `soft_limit` settings, or disable collectors entirely for critical workflows.
- How do I capture custom metrics like API call latency or third-party service logs?
- Extend the `DataCollector` class to create custom collectors. For example, log API call times with `Debugbar::addMeasure('api_call', $startTime, 'ms')` or override `collect()` in a custom collector. Document your custom collectors in the config to avoid confusion during debugging sessions.
- Is it safe to use Laravel Debugbar in CI/CD pipelines or automated tests?
- Use it cautiously in CI/CD. Enable collectors like `db` for query assertions but disable storage (`debugbar.storage.open = false`) to avoid cluttering logs. Exclude Debugbar from production-like tests by checking `APP_ENV` in middleware. For load testing, disable collectors entirely to measure true performance.
- How do I integrate Laravel Debugbar with Livewire or Blade components?
- Debugbar works natively with Blade via `{{ debug() }}` and `{{ stopwatch() }}` tags. For Livewire, install the `livewire` collector (`composer require barryvdh/laravel-debugbar-livewire`) and enable it in `config/debugbar.php`. This provides insights into Livewire hook execution, property updates, and Alpine.js interactions.
- What alternatives exist if Laravel Debugbar feels too heavy for my project?
- Consider `tightenco/laravel-query-logger` for lightweight query logging, `spatie/laravel-query-logger` for database-specific insights, or `barryvdh/laravel-ide-helper` for IDE autocompletion. For full-stack debugging, `laravel-debugbar` is unmatched, but for minimalism, `spatie/laravel-log` or `laravel-debugging` (experimental) may suffice.
- How do I exclude sensitive routes or admin panels from Debugbar output?
- Use middleware to disable Debugbar for specific routes. For example, in `app/Http/Middleware/DisableDebugbar.php`, check `Route::current()->getName()` and call `debugbar()->disable()`. Alternatively, exclude routes in `config/debugbar.php` with `debugbar.excluded_routes`. Always restrict storage (`debugbar.storage.open`) to local environments.
- Can I use Laravel Debugbar to debug console commands or Artisan tasks?
- Yes, manually enable Debugbar in commands with `debugbar()->enable()`. For example, add `Debugbar::info('Command started')` at the start of your command class. This logs command execution time, memory usage, and any custom metrics you add. Disable storage (`debugbar.storage.open = false`) to avoid persisting command data.