Laravel Telescope

repository·5.x·Indexed 26 days ago

https://github.com/laravel/telescope

An elegant debug assistant for the Laravel framework that provides deep visibility into application activity. It monitors and records incoming requests, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, and variable dumps to enhance the local development environment.

Tokens
1.7K
Snippets
4
Records
23
Agent score
89%

What's inside Laravel Telescope

  1. Overview of Laravel Telescope

    5.x

    Laravel Telescope is a debug assistant for Laravel applications. It provides deep visibility into application activity, including:

    • Incoming requests
    • Exceptions
    • Log entries
    • Database queries
    • Queued jobs
    • Mail and notifications
    • Cache operations
    • Scheduled tasks
    • Variable dumps
  2. Publish assets and clear view cache during upgrades

    5.x

    When upgrading Laravel Telescope, you must publish the updated assets and clear the application's view cache to ensure the dashboard renders correctly.

    php artisan telescope:publish
    php artisan view:clear
  3. Publish migrations when upgrading to Telescope 5.0

    5.x

    In Telescope 5.0, migrations are no longer automatically loaded from the package's internal directory. You must manually publish the Telescope migrations to your application's migration directory using the telescope-migrations tag.

    php artisan vendor:publish --tag=telescope-migrations
  4. Install Telescope via the CLI

    5.x

    Run the telescope:install command to automate the installation of Telescope resources. This command performs the following actions:

    1. Publishes the telescope-provider tag.
    2. Publishes the telescope-config tag.
    3. Publishes the telescope-migrations tag.
    4. Registers the App\Providers\TelescopeServiceProvider in your application's configuration.
  5. Publish Telescope assets and configuration

    5.x

    You can publish Telescope's configuration, migrations, and service provider stubs using the following Artisan commands or by specifying the tag in your publish command:

    • Configuration: php artisan vendor:publish --tag=telescope-config (publishes config/telescope.php)
    • Migrations: php artisan vendor:publish --tag=telescope-migrations (publishes database migrations)
    • Service Provider Stub: php artisan vendor:publish --tag=telescope-provider (publishes app/Providers/TelescopeServiceProvider.php)
  6. Configure Telescope routes and middleware

    5.x

    Telescope's access and routing are controlled via the telescope configuration keys.

    • telescope.path: Defines the URL prefix for the Telescope dashboard.
    • telescope.domain: Allows restricting the dashboard to a specific domain.
    • telescope.middleware: An array of middleware to apply to the Telescope routes. By default, it uses ['web'] and is wrapped in a telescope middleware group which includes SentinelMiddleware::class:telescope.
    • telescope.enabled: If set to false, Telescope will not boot its routes or services.
  7. Configure Database Storage Driver

    5.x

    When using the database driver (telescope.driver set to database), you can configure the following settings in config/telescope.php:

    • telescope.storage.database.connection: The database connection to use for storing entries.
    • telescope.storage.database.chunk: The chunk size used when processing entries in the database.
  8. Configure ClientRequestWatcher options

    5.x

    The ClientRequestWatcher monitors outgoing HTTP client requests and responses. You can customize its behavior using the following configuration options within the watcher's options array:

    • ignore_hosts: An array of hostnames to ignore. If a request's host matches an entry in this list, the response will not be recorded.
    • size_limit: An integer representing the maximum allowed size for content (in kilobytes) before it is marked as Purged By Telescope. The default is 64.
  9. Define the viewTelescope Gate

    5.x

    To restrict Telescope access in non-local environments, define a Laravel Gate named viewTelescope. This gate is typically used inside the Telescope::auth closure to validate if the authenticated user has permission to view the dashboard.

    Gate::define('viewTelescope', function ($user) {
        return in_array($user->email, [
            // Add authorized emails here
        ]);
    });