Debugging production issues blindly wastes time. Laravel Telescope provides elegant insights into requests, exceptions, queries, and jobs. At ZIRA Software, Telescope has reduced debugging time by 70%.
Installation
composer require laravel/telescope
php artisan telescope:install
php artisan migrate
Request Monitoring
See every HTTP request:
- Request data (headers, body, session)
- Response data and status
- Middleware execution
- Route information
// Automatically captured
// Visit /telescope to view dashboard
Query Monitoring
Identify slow queries:
// Telescope shows:
// - Query SQL
// - Bindings
// - Execution time
// - Connection
// - Location in code
// Example slow query alert
DB::listen(function ($query) {
if ($query->time > 100) {
// Telescope captures this automatically
}
});
Exception Tracking
All exceptions captured:
- Stack trace
- Request context
- User information
- Environment data
Job Monitoring
class ProcessOrder implements ShouldQueue
{
// Telescope tracks:
// - Job payload
// - Execution time
// - Attempts
// - Failures
}
Performance Insights
Monitor application health:
- Slow requests
- Memory usage
- Database query count
- Cache hit rates
Production Configuration
// config/telescope.php
'enabled' => env('TELESCOPE_ENABLED', true),
// Limit recording in production
'only_exceptions' => [
\App\Exceptions\CriticalException::class,
],
// Prune old entries
'pruning' => [
'enabled' => true,
'days' => 7,
],
Watchers
Customize what Telescope monitors:
'watchers' => [
Watchers\CacheWatcher::class => env('TELESCOPE_CACHE_WATCHER', true),
Watchers\CommandWatcher::class => env('TELESCOPE_COMMAND_WATCHER', true),
Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', true),
Watchers\EventWatcher::class => env('TELESCOPE_EVENT_WATCHER', true),
Watchers\ExceptionWatcher::class => true,
Watchers\JobWatcher::class => true,
Watchers\LogWatcher::class => env('TELESCOPE_LOG_WATCHER', true),
Watchers\MailWatcher::class => true,
Watchers\ModelWatcher::class => env('TELESCOPE_MODEL_WATCHER', true),
Watchers\NotificationWatcher::class => true,
Watchers\QueryWatcher::class => env('TELESCOPE_QUERY_WATCHER', true),
Watchers\RequestWatcher::class => true,
],
Authorization
Restrict access:
// app/Providers/TelescopeServiceProvider.php
protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
'contact@zirasoftware.com',
]);
});
}
Conclusion
Telescope transforms debugging from guesswork to data-driven problem solving. Essential for modern Laravel development.
Need debugging assistance or Laravel optimization? Contact ZIRA Software for expert support.