4

Laravel Telescope Installation and Configuration Tutorial

 2 years ago
source link: https://www.laravelcode.com/post/laravel-telescope-installation-and-configuration-tutorial
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Laravel Telescope Installation and Configuration Tutorial

  253 views

  2 months ago

Laravel

Laravel provide some official packages which are easy to use with its applications. Telescope is one of the best package to use for developers. Using this package developers can keep track of whole applicaion activity. It allows various features which you can enable or disable according to your need.

In this tutorial we will show you the steps to install and how can you manage the various options available in the package.

Step - 1 : Create new laravel application

First we need to create laravel 8 application in our local system help of run the following command in terminal.

composer create-project --prefer-dist laravel/laravel telescope_demo

Step - 2 : Install package

composer require laravel/telescope

Step - 3 : Publish and run migration

php artisan telescope:install 

php artisan migrate

Step - 4 : Changes for other than local environment

Telescope by default does not allow access to the data stored by it while not in local environment. Here telescope decides the environment from value of "APP_ENV" of .env file.

To access it from other environment we need to mention which users are allowed in the service provider "TelescopeServiceProvider.php" file as below.

Solution 1:

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

Solution 2:

protected function gate()
{
    Gate::define('viewTelescope', function ($user) {
        return in_array($user->id, [
    		10
   		];
    });
}

Step - 5 : Additional settings

Prune

By default all data will be removed after 24 hours. You can customize this by scheduling telescope:prune command. You can schedule command by inserting following line in schedule function of Kernel.php file.

protected function schedule(Schedule $schedule)
{
	$schedule->command('telescope:prune --hours=48')->daily();        
}

Other settings

Telescope has its own seperate configuration file available at config/telescope.php. You can disable the unnecessary entries from here. by default all the watchers are enabled.

All the watchers listed under 'watchers' in config file.

Step - 6 : View Telescope dashboard

You can view telescope dashboard using following path.

http://localhost:8000/telescope

I hope it will help you.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK