Step by Step guide to integrate Telescope in Laravel 12
Laravel is a powerful PHP framework loved by developers for its elegance and simplicity. Laravel has many packages and feature one of the most used and must have package to have is Telescope. When you’re building applications, debugging, Monitoring, Measuring performance it can be headache . That’s where Laravel Telescope comes into the picture! 🚀
In this article, I’ll guide you step-by-step on how to install and integrate Telescope into your Laravel project smoothly.
🌟 What is Laravel Telescope?
Laravel Telescope is a debug assistant for Laravel framework. It gives a beautiful dashboard where you can monitor your application in real-time. Its very very helpful when your application is in production.
With Telescope, you can see:
🛠️ Requests
💾 Database queries
📤 Queued jobs
📩 Emails
⚠️ Exceptions & logs
📡 Events and more!
🤔 Why is Laravel Telescope Useful?
Imagine you application in running on PRODUCTION and it has many errors in different sections like some jobs are failed, some Api's had thrown exceptions, some queries are taking too much time, As a developer we can log these things one by one and can check the logs in larave.log file. But imagine this file is too big and finding out each and every log is traumatic. In such case Telescope makes it easier by providing beautiful and segregated sections for different activities.
Here are the summerized reasons why developers ❤️ Telescope:
✅ Real-time debugging: Instantly view what’s happening inside your app.
✅ Performance monitoring: See slow queries or job failures.
✅ Error tracking: Catch exceptions and fix them fast.
✅ Request tracking: Understand how your app handles user requests.
Whether you're in development or testing mode, Telescope is your friend in need. 👨💻👩💻
🛠️ Install and Integrate Telescope
Use the following composer commands one by one to install and integrate telescope properly in you project.
composer require laravel/telescope
Once its installed, use the following command to publish the telescope assets
php artisan telescope:install
Run migrate command to create tables for Telescope
php artisan migrate
That's it. You have now successfully installed and integrated Telescope in your Laravel project. You can now use the following URL to access telescope.
http://localhost:8000/telescope
🔒 Controlling Access to Telescope
By default, Telescope is only available in the local environment.
To customize who can access it, edit this method in TelescopeServiceProvider.php and add emails to whitelist, so that users logged in with the whitelisted email id's can access Telescope in PRODUCTION as well.
protected function gate(): void { Gate::define('viewTelescope', function ($user) { return in_array($user->email, [ 'email_one@yopmail.com', 'email_two@yopmail.com' ]); }); }
🔒Other Configurations
You can also checkout the Telescope configuration file available on config/telescope.php, where you can customize the telescope path, enable or disable telescope etc.