Laravel 11 - Telescope.

Touseef Afridi
16 Sep 24

Laravel 11 - Telescope.

In this tutorial, we'll cover how to integrate Laravel Telescope in a Laravel 11 application. Telescope provides real-time monitoring of requests, queries, and logs, simplifying debugging.


If you're a video person, feel free to skip the post and check out the video instead!


Quick Overview

This guide walks you through setting up Laravel Telescope in a fresh Laravel project with Breeze authentication. We begin by creating a new Laravel application with Breeze for authentication scaffolding, using either the global Laravel installer or Composer. After that, we access the project directory and install the Laravel Telescope package, which helps with monitoring and debugging the application. We then publish the necessary assets, configurations, and run the database migrations required for Telescope to function. Finally, we test the installation by starting the Laravel development server and accessing the Telescope dashboard in the browser. This tutorial provides a strong foundation for integrating Telescope into your Laravel applications, giving you powerful tools for tracking application events, database queries, and more in real time.

Step # 1 : Create a Fresh Laravel Project with Breeze Auth.

Start by creating a new Laravel application with Breeze authentication to get up and running quickly with basic authentication scaffolding. If you have Laravel installed globally, run the following command to create a new project.
laravel new telescope
Alternatively, you can use Composer to create a Laravel project by running.
composer create-project laravel/laravel --prefer-dist telescope
After running the command, you'll be prompted with the following setup options.
  • Install Starter Kit: Select Breeze to include basic authentication scaffolding.
  • Choose Stack: Pick Blade as the templating engine.
  • Dark Mode Support: Choose No to skip dark mode styling.
  • Testing Framework: Select Pest for a modern testing experience.
  • Initialize Git Repo: Choose No if you prefer setting it up manually later.
  • Select Database: Pick MySQL as your database engine.
  • Run Default Migrations: Select Yes to create the default tables.

By completing these steps, you'll have a clean Laravel project set up with Breeze for authentication, using Blade for frontend views, Pest for testing, and MySQL for your database. This provides a strong foundation for building secure, testable, and customizable Laravel applications.

Step # 2 : Access the project.

Open your terminal (such as Git Bash, Command Prompt, or any terminal you prefer) and navigate to the root directory of your Laravel project. For example, if your project is located in C:\xampp\htdocs\telescope, run the following command.
cd c:xampp/htdocs/telescope
Make sure to update the path according to your system. Being inside the project directory allows you to manage and work with your Laravel application efficiently.

Step # 3 : Install Telescope.

To get started with Laravel Telescope, first, install the Telescope package by running the following command.
composer require laravel/telescope
This will add the Laravel Telescope package to your project and ensure that all the necessary files, dependencies, and configurations are in place. Next, run the following command to publish the required assets, configuration files, and service providers needed for Telescope to function properly in your application.
php artisan telescope:install
This will set up everything that Telescope needs to work seamlessly within your Laravel project. It will create the necessary configuration files, assets, and service providers to ensure Telescope integrates smoothly with your application. After installing Telescope, run the database migrations to create the required tables for storing the monitoring and debugging data that Telescope collects. Use the following command.
php artisan migration
This will create the necessary database tables, such as the ones for storing logs, requests, and other useful debugging data. Once these steps are completed, Telescope will be successfully installed and ready to use.

Step # 4 : It's time to test.

Now it's time to test if everything is set up correctly. Start the Laravel development server by running the following command.
php artisan serve
Once the server is running, open your browser and navigate to the following URL: http://127.0.0.1:8000/telescope. This will allow you to access the Telescope dashboard and start monitoring your application.


Laravel Telescope is an advanced debugging and monitoring tool designed to provide detailed insights into the inner workings of your Laravel application. It automatically records key actions within your app, helping developers easily identify performance bottlenecks, errors, and other issues. One of its main features is the ability to log every page request. When a user visits a page, Telescope captures detailed information about the request, including the HTTP method (GET, POST, etc.), the requested URL, the response status code, and how long it took to process the request. This gives you an immediate overview of your app's performance at any given time.
Telescope also tracks every database query executed during a request. It logs each SQL query along with its execution time, allowing you to quickly spot slow or inefficient queries. This is especially useful for optimizing database performance and ensuring that your queries run efficiently. If you’re working with complex queries or large datasets, Telescope helps you identify issues early on.
Additionally, Laravel Telescope monitors your background tasks, such as queued jobs and scheduled tasks. It logs the status of each job, how long it took to process, and whether it failed or succeeded. This visibility is essential for maintaining the reliability of background processing in your application.
Another crucial feature is exception tracking. Telescope automatically logs exceptions that occur in your application, displaying error messages, stack traces, and any other relevant context. This makes troubleshooting easier and faster, as you can quickly pinpoint the source of the issue.
All of this data is accessible via the /telescope route in your browser. The dashboard offers an intuitive interface to explore all the logged data, making Laravel Telescope a must-have tool for any Laravel developer looking to monitor, debug, and optimize their application effectively.

Conclusion

By following this guide, you've successfully integrated Laravel Telescope into your Laravel project. You've set up a fresh Laravel application with Breeze authentication, installed the Telescope package, and published the required assets and configurations. You've also run the necessary migrations to create the required tables for monitoring and debugging. After testing the setup, you can now access the Telescope dashboard to track key application events, database queries, queued jobs, and more. With Telescope in place, you'll have real-time insights into your application's performance and issues. You can further enhance this setup by exploring more Telescope features or integrating it with advanced logging or monitoring solutions.
For more details, please refer to the Laravel Telescope documentation.
Share this with friends!


"Give this post some love and slap that 💖 button as if it owes you money! 💸😄"
0

0 Comments

To engage in commentary, kindly proceed by logging in or registering