laravel/telescope
Laravel Telescope is an elegant debug assistant for Laravel, showing rich insight into requests, exceptions, logs, database queries, jobs, mail, notifications, cache, scheduled tasks, and more—ideal for local development and troubleshooting.
Installation:
composer require laravel/telescope --dev
php artisan telescope:install
This publishes the migration, config, and assets, then registers the Telescope service provider.
Database Migration:
php artisan migrate
Creates the telescope_entries table.
Middleware Registration:
Add TelescopeServiceProvider::class to config/app.php under providers (if not auto-discovered).
Add TelescopeScreenshots::class to app/Http/Middleware/ and register it in app/Http/Kernel.php:
'web' => [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TelescopeScreenshots::class, // Add this line
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
// ...
],
First Use:
Visit http://your-app.test/telescope (or /telescope in production if configured). Authenticate via Laravel’s default auth (e.g., php artisan make:auth if using older Laravel).
dd() or dump() calls.method, uri, or tags (e.g., api).public function handle($request, Closure $next) {
$request->telescope()->tag('api', 'v1');
return $next($request);
}
duration (descending).telescope:clear to reset data:
php artisan telescope:clear
status (e.g., failed).config/telescope.php:
'queues' => [
'delay' => true, // Show delayed jobs
],
dd() with Telescope for persistent debugging.
dump() or dd() in your code.context (e.g., route, controller).AppServiceProvider:
use Illuminate\Support\Facades\Telescope;
public function boot() {
Telescope::extend(function ($telescope) {
$telescope->watchVariableDumps(function ($dumper) {
$dumper->with(new CustomDumper());
});
});
}
abort(500)).// In a middleware or service provider
Telescope::filter(function ($entry) {
return !$entry instanceof \Illuminate\Exceptions\Handler;
});
TELESCOPE_ENABLED=false in .env:
TELESCOPE_ENABLED=false
protected function authenticate(): void {
if (! auth()->check()) {
abort(403);
}
}
use Illuminate\Support\Facades\Telescope;
Telescope::extend(function ($telescope) {
$telescope->watchCommands(function ($command) {
return [
'command' => $command,
'exit_code' => 0,
];
});
});
use Illuminate\Support\Facades\Telescope;
Telescope::screen(function () {
return \App\Screens\ApiMetricsScreen::make();
});
php artisan queue:work --telescope
if (app()->environment('ci')) {
Telescope::ignoreRoutes(function () {
return true;
});
}
Performance Overhead:
DB::enableQueryLog() and compare with Telescope data.Database Bloat:
php artisan telescope:clear
config/telescope.php:
'retention' => 14, // Days to keep entries
Authentication Bypass:
Telescope::auth(function () {
return auth()->check();
});
Missing Related Entries:
TelescopeScreenshots middleware is registered.telescope()->associate():
$entry = Telescope::entry('request');
$entry->associate($queryEntry);
SQL Formatting Issues:
sql-formatter package or manually format in Telescope’s query view.Disable Specific Features:
config/telescope.php:
'enable-queries' => env('TELESCOPE_QUERIES', false),
'enable-logging' => env('TELESCOPE_LOGGING', false),
Filter Noisy Entries:
Telescope::ignoreRoutes(function ($request) {
return $request->ip() === '127.0.0.1';
});
Inspect Binary Content:
Telescope Not Loading Assets:
php artisan telescope:assets
npm run dev
PHP Errors in Telescope:
storage/logs/laravel.log for Telescope-specific errors.php artisan view:clear
Telescope::extend(function ($telescope) {
$telescope->watchCustomEvents(function ($event) {
return [
'name'
How can I help you explore Laravel packages today?