Laravel Telescope and its utility
Laravel Telescope is a new application debugging assistant from Laravel. It's open source, free on GitHub. Built by Mohamed Said and Taylor Otwell.
Laravel Telescope is open-source software licensed under the MIT license. Telescope provides insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, variable dumps and more. The telescope makes a wonderful companion to your local Laravel development environment.
Laravel Telescope utilities
You'll pull it into your applications as a third-party dependency via Composer.
After publishing Telescope's assets, its primary configuration file will be located at config/telescope.php. This configuration file allows you to configure your watcher options and each configuration option includes a description of its purpose, so be sure to thoroughly explore this file.
Without pruning, the telescope_entries table can accumulate records very quickly. To mitigate this, you should schedule the telescope:prune Artisan command to run daily.
By default, all entries older than 24 hours will be pruned. You may use the "hours" option when calling the command to determine how long to retain Telescope data.
Telescope exposes a dashboard at /telescope. By default, you will only be able to access this dashboard in the local environment. Within your app/Providers/TelescopeServiceProvider.php file, there is a gate method. This authorization gate controls access to Telescope in non-local environments. You are free to modify this gate as needed to restrict access to your Telescope installation.
Here’s the list of tabs mention that you can inspect in the Telescope UI:
This tab allows you to see all of the HTTP requests that come into your application. You'll be able to inspect all the HTTP requests and all sorts of useful info about each request.
The commands tab lists all the commands that have been run and their exit codes. When you dive in you can also see all of their arguments, options, and related items.
Lists the scheduled tasks that have been run. On each task detail page, see all of their scheduling information like their cron schedule (e.g. * * * * *).
The jobs tab lists out all of the jobs that have run or all running. It's similar to Horizon, but Horizon is Redis-only and isn't just a UI, and it also interacts with how your queue workers are running. Telescope, on the other hand, is just a UI, but it also works for all queue drivers. On the jobs list page, you'll be able to see the job name, which queue and connection it ran on, its status, and when it happened.
On the job detail page, you'll be able to see all of that data and more: hostname, job's fully-qualified class name, connection, queue, # of tries, timeout, tags.
Logs all exceptions and allows you to inspect each. This will show you similar data to the other tabs, like hostname, type, request, tags, authenticated user.
The logs tab shows you the basic log message, level, and when it happened for all log items.
If you use the dump() method in your code, in Telescope, you'll see the dumps in Telescope but not your actual application. This gives you dd() style output of your data without it messing up your normal page load. Each dump also links to the request which generated it. If you leave the dump screen, all of a sudden your dumps show up in your browser again.
List of all your DB queries--like the debug bar. How long they took, jump in and view the full query, which requests triggered it, etc. Nice formatted view.
You can see create, update, delete events; shows the changes that were made, etc.
Shows a list of all your events. You can see which events were broadcast with a tag; see a list of all listeners and dig into which called.
Shows a list of all emails that were sent; who the recipients are; when it happened; whether it's queued and then when the queue kicks it out. Can see the email subject, and when you dig into it you also see a preview of the email like MailTrap. Can even download the raw .eml file and open it in your client of choice.
Shows all notifications, what type they were, etc. No previews since some notifications aren't preview-able, but if it's a mail notification you'll also see it there. If notification was queued, you can also see it under the Jobs section on the request. Lots of angles to get much of this data.
Shows cache hits and misses abd updates etc. Shows the key, the data, when it expires, can see the request that triggered it and also on the request page you can see all the cache hits/misses for that request.
It's similar to a cache. How long they took, when it happened, which request initiated, etc.
Telescope can run locally and on production and has built-in authorization and tools for protecting private data. It provides access to similar data from multiple different angles, has a bevy of configuration options, and allows for robust tagging and filtering. Consider putting it on a separate database.
Taylor mentioned on Twitter later you can add filters to ensure private data doesn't get logged.
You can share your experiences with us in the comments section. Thank you!