Skip to main content

How to Set Up & Use Laravel Telescope

How to Set Up & Use Laravel Telescope

Laravel Telescope is a powerful debugging and monitoring tool built by the Laravel team. It provides detailed insights into your application’s requests, exceptions, database queries, jobs, mail, notifications, cache, and more—all in an elegant dashboard.

๐Ÿš€ What is Laravel Telescope?

Laravel Telescope acts as a “developer’s black box,” recording everything that happens within your Laravel app. It’s especially useful during development and staging to track performance issues, failed jobs, or unexpected behavior.

๐Ÿงฉ Step 1: Install Telescope

Run the following Composer command in your Laravel project directory:

composer require laravel/telescope --dev

The --dev flag ensures Telescope is only installed in your local development environment.

⚙️ Step 2: Publish Telescope Assets

Once the package is installed, publish the Telescope service provider and assets:

php artisan telescope:install

Then run your database migrations to create the necessary tables:

php artisan migrate

๐Ÿ” Step 3: Protect Telescope in Production

By default, Telescope should not be accessible in production for security reasons. Laravel provides an environment-based check in app/Providers/TelescopeServiceProvider.php:

protected function gate()
{
    Gate::define('viewTelescope', function ($user) {
        return in_array($user->email, [
            'admin@example.com',
        ]);
    });
}

This ensures that only authorized users can view Telescope data if you ever enable it in production.

๐Ÿ“Š Step 4: Access the Telescope Dashboard

Start your local development server:

php artisan serve

Then open Telescope in your browser at:

http://localhost:8000/telescope

You’ll see an elegant dashboard with tabs like Requests, Queries, Exceptions, Logs, Mail, and more.

๐Ÿง  Step 5: Exploring Telescope Features

  • Requests: View incoming HTTP requests and responses.
  • Exceptions: Track all errors and exceptions with full stack traces.
  • Queries: Monitor SQL queries and execution times.
  • Jobs & Queues: Debug queued jobs, failed jobs, and events.
  • Cache: Inspect cache hits and misses.
  • Mail & Notifications: View emails and notifications sent by your app.
  • Logs: Centralized log entries for easy debugging.

๐Ÿ’ก Step 6: Managing Telescope Data

Telescope stores data in your database. To prevent it from growing too large, you can prune old entries:

php artisan telescope:prune --hours=48

You can even schedule pruning automatically by adding this to your app/Console/Kernel.php:

protected function schedule(Schedule $schedule)
{
    $schedule->command('telescope:prune --hours=48')->daily();
}

๐ŸŽฏ Conclusion

Laravel Telescope is an essential tool for any Laravel developer. Whether you’re debugging complex queries, tracking failed jobs, or optimizing performance, Telescope gives you the visibility you need to build better, more stable applications.

Start using it today, and take control of your Laravel app’s inner workings with ease!


Written by Rana Saha — Software Developer & Technical Blogger.

Comments

Popular posts from this blog

How to Use L5-Swagger for API Documentation in Laravel

Integrating Swagger in Laravel: Annotations, JSON, and YAML What is Swagger? Swagger (OpenAPI) is a powerful tool for generating interactive API documentation. It helps developers understand and test your API easily. ✅ Step-by-Step Guide to Setup L5-Swagger 1. Install L5-Swagger Package composer require "darkaonline/l5-swagger" 2. Publish Config & View Files This command publishes the config file to config/l5-swagger.php : php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" 3. Configure Swagger (Optional) Edit the file config/l5-swagger.php to update: API Title Base Path Directories to scan for annotations 4. Add Swagger Annotations Add these before your controller class: /** * @OA\Info( * version="1.0.0", * title="Your API Title", * description=...

How to Send Emails in Node.js using Nodemailer and Ethereal

How to Send Email in Node.js using Nodemailer Email functionality is essential in modern web applications. Whether you're sending confirmation emails, password resets, or notifications, Node.js with Nodemailer makes this simple. In this blog, we'll walk through setting up email sending using Node.js , Express , and Ethereal Email for testing. ๐Ÿงพ Prerequisites Node.js installed Basic knowledge of Express.js Internet connection ๐Ÿ“ Project Structure project-folder/ ├── index.js ├── .env ├── package.json └── app/ └── controller/ └── emailSendController.js ๐Ÿ“ฆ Step 1: Install Dependencies npm init -y npm install express nodemailer dotenv npm install --save-dev nodemon ๐Ÿ” Configure nodemon (Optional but Recommended) Update your package.json with a custom start script: "scripts": { "start": "nodemon index.js" } ๐Ÿ” Step 2: Create a .env File Create a .env file a...

Realtime Device Tracker using Node.js, Socket.IO & Leaflet

Realtime Device Tracker using Node.js, Socket.IO & Leaflet In this tutorial, you’ll learn how to build a realtime location tracking application that uses the browser’s GPS, Socket.IO for live communication, and Leaflet.js to display users on a map. ๐Ÿš€ Project Overview Backend: Node.js, Express.js, Socket.IO Frontend: HTML, Leaflet.js, Socket.IO client Features: Live GPS tracking, multi-user map, disconnect cleanup ๐Ÿ“ Folder Structure project-root/ ├── app.js ├── package.json ├── src/ │ ├── public/ │ │ ├── css/ │ │ │ └── style.css │ │ └── js/ │ │ └── script.js │ ├── routes/ │ │ └── routers.js │ ├── socket/ │ │ └── socketHandler.js │ └── views/ │ └── index.ejs ๐Ÿง  How It Works Each user shares their location using the browser's navigator.geolocation API. Location is sent to the server via Socket.IO . The server broadcasts each user’s position to all clien...