Laravel Telescope

We set up Laravel’s powerful debug assistant and take an in-depth look at its features.

Introduction:

This is where Laravel Telescope comes in. The core team at Laravel have developed Telescope as a fully featured debug assistant for your Laravel projects. In this article we’ll look at how to install Telescope on your local or production environment and we’ll give an overview of its key features.

Installing Laravel Telescope:

composer require laravel/telescope

If you are only using Telescope in your local environment you can add the --dev flag as below:

composer require laravel/telescope --dev

You’ll then need to publish its assets and run a database migration using the following:

php artisan telescope:install 
php artisan migrate

If you’re installing for local environments only, after running the above commands there are a couple extra steps: in /config/app.php remove the following line from the Application Service Providers... section:

App\Providers\TelescopeServiceProvider::class,

Then in your app/Providers/AppServiceProvider.php, add the following:

use App\Providers\TelescopeServiceProvider;

And in the register() method:

if ($this->app->isLocal()) {
$this->app->register(TelescopeServiceProvider::class);
}

If you are using Telescope in a production environment then by default only specified users will be able to access the Telescope dashboard. These can be added in the gate() method of the app/Providers/TelescopeServiceProvider.php file in the following way:

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

You could instead choose to specify users by ID if you prefer:

return in_array($user->id, [
1, 2, 3,
]);

Or you could even store your permitted IDs as an environment variable in your .env file.

Configuration:

Features:

Requests

Commands

Schedule

Jobs

Exceptions

Logs

Dumps

Queries

Models

Events

Mail

Notifications

Gates

If there are Gates or Policies you don’t want logged, you can add them to the ignore_abilities key in the telescope.php config file:

Watchers\GateWatcher::class => [
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => ['id-ten'],
'ignore_packages' => true,
],

Cache

Redis

Note that you will have to add the following to the boot() method in your AppServiceProvider.php to allow Redis events to display in Telescope:

Redis::enableEvents();

Finally…

Like this story? Please follow us on Twitter.

At Welcm we design, develop and support websites, bespoke software and mobile apps. We specialise in the Laravel framework.

If you have a project you would like to discuss please send an enquiry from our contact page, email us at enquiries@welcm.uk or call us on 01252 950 650.

We also make Visitor Management Easy at https://welcm.ly

Originally published at https://welcm.uk.

We design, develop and support websites, apps and custom software. Find out more at https://welcm.uk. We also make Visitor Management Easy — https://welcm.ly