Laravel Telescope is a debugging and introspection tool for Laravel applications. It provides a beautiful, easy-to-use interface for monitoring and debugging your application during development. To configure and use Laravel Telescope, follow these steps:
Install Telescope using Composer:
composer require laravel/telescope |
Publish the Telescope configuration file and assets:
php artisan telescope:install |
Run the migration to create the necessary database tables:
php artisan migrate |
Add the Telescope middleware to your App\Http\Kernel.php
file within the $middleware
array:
protected $middleware = [ // ... \Laravel\Telescope\Http\Middleware\TelescopeMiddleware::class, ]; |
By default, Telescope is only available in the local environment. If you want to enable Telescope in other environments, you can configure the authorization gate. Open the App\Providers\TelescopeServiceProvider.php
file and update the gate
method:
/** * Register the Telescope gate. * * This gate determines who can access Telescope in non-local environments. * * @return void */ protected function gate() { Gate::define('viewTelescope', function ($user) { return in_array($user->email, [ 'your-email@example.com', ]); }); } |
You can access Telescope by visiting the /telescope
route in your browser. For example: http://your-app.local/telescope
.
Telescope provides various tabs to monitor your application, including requests, commands, jobs, exceptions, and more. Explore the tabs to gather insights into your application's behavior during development.
Additionally, Telescope allows you to customize and extend its functionality. Check the official documentation for more advanced features and customization options: Telescope Documentation
Remember to remove Telescope from your production environment or secure it properly to avoid exposing sensitive information.
=== Happy Coding :)