Laravel Telescope Tutorial Example

Laravel Telescope Tutorial Example

Laravel 8 telescope example; In this tutorial, you will learn how to install and configure telescope in laravel 8. And how to use telescope in laravel 8.

Using Laravel Telescope can debug requests, exceptions, databases, cache, and much more in real-time by accessing a specific route in your local or production environment in laravel 8 app.

Laravel Telescope Tutorial Example

Follow the below givens simple steps to install, configure and use telescope in laravel 8:

Step 1 – Install Telescope

In this step, open command prompt and navigate to your laravel 8 app by using this command:

cd /project folder name

And run the following command to install telescope in laravel 8 app:

composer require laravel/telescope

If you want to use telescope in local environment, so you can use the below command:

composer require laravel/telescope --dev

Step 2 – Migrate Tables

In this step, run the following commands on command prompt to migrate tables into database:

php artisan telescope:install

php artisan migrate

Step 3 – Configure Telescope

In this step, an open app.php file, which is located inside the config directory. And configure telescope providers in laravel 8 app:

App\Providers\TelescopeServiceProvider::class,

After that, open AppServiceProvider.php file, which is located inside app/providers directory and add the following lines of code into register() method:

public function register()
{
    if ($this->app->isLocal()) {
        $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
        $this->app->register(TelescopeServiceProvider::class);
    }
}

Step 4 – Configure Dashboard Authorization

In this step, 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:

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

Step 5 – Start Development Server

In this step, run the following command on command prompt to start developement server:

php artisan serve

Step 6 – Test Laravel Telescope

Now, open your browser and use the following command to test laravel 8 telescope:

http://127.0.0.1:8000/telescope

When you will fire the above url on browser, you will look like in the following images:

Recommended Laravel Posts

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *