VOOZH about

URL: https://deepwiki.com/hypervel/telescope/5-console-commands

⇱ Console Commands | hypervel/telescope | DeepWiki


Loading...
Last indexed: 7 February 2026 (146f77)
Menu

Console Commands

Purpose and Scope

This page documents Telescope's console command system, which provides administrative tools for managing recorded monitoring data and system state. These commands enable developers and operators to clear entries, control recording state, prune old data, and publish package assets.

For information about the web-based management interface, see Web Interface. For details about the storage repositories these commands interact with, see Repository Pattern.


Command Registration and Bootstrap

Telescope registers five management commands during service provider initialization. The TelescopeServiceProvider registers all commands unconditionally in its boot() method, making them available regardless of whether Telescope monitoring is enabled.

Command Registration

Command ClassSignaturePrimary Function
Console\ClearCommandtelescope:clearDelete all entries from storage
Console\PauseCommandtelescope:pauseStop data collection temporarily
Console\ResumeCommandtelescope:resumeResume data collection
Console\PruneCommandtelescope:pruneRemove old entries based on retention policy
Console\PublishCommandtelescope:publishExport migrations, assets, and config files

The registration occurs in src/TelescopeServiceProvider.php98-107:


Sources: src/TelescopeServiceProvider.php98-107


Command Architecture and Lifecycle

The following diagram illustrates how console commands integrate with Telescope's storage layer and configuration system:


Command Execution Flow


Sources: src/TelescopeServiceProvider.php98-107 src/TelescopeServiceProvider.php163-179


telescope:clear Command

The ClearCommand provides a mechanism to delete all recorded Telescope entries from storage. This command is typically used during development or when resetting monitoring data.

Implementation

The command interacts with the ClearableRepository contract, which abstracts the storage deletion logic:

src/Console/ClearCommand.php1-31


Behavior

AspectDetails
Dependency InjectionReceives ClearableRepository via constructor injection
Storage OperationsCalls clear() method to remove all entries
OutputDisplays confirmation message: "Telescope entries cleared!"
Affected Tablestelescope_entries, telescope_entries_tags, telescope_monitoring
SafetyNo confirmation prompt - executes immediately

Storage Interaction Diagram


Sources: src/Console/ClearCommand.php1-31 src/Contracts/ClearableRepository.php


telescope:pause and telescope:resume Commands

These commands control Telescope's recording state by managing a pause flag in the cache system. When paused, Telescope stops collecting new monitoring data but retains previously recorded entries.

PauseCommand Structure


Expected Behavior

CommandSignatureActionCache KeyCache ValueDuration
PauseCommandtelescope:pauseStop recordingtelescope:pause-statetrueForever
ResumeCommandtelescope:resumeResume recordingtelescope:pause-stateDeletedN/A

Integration with Recording Logic

When paused, the Telescope::isRecording() method checks for the pause flag before allowing data collection. All watchers call this method before recording entries, ensuring consistent behavior across the system.


Sources: src/TelescopeServiceProvider.php100-107 src/Console/PauseCommand.php src/Console/ResumeCommand.php


telescope:prune Command

The PruneCommand removes old Telescope entries based on the configured retention policy. This command is typically run on a schedule to prevent unbounded database growth.

Prune Logic

ConfigurationPurposeDefault Value
telescope.retention.hoursHours to keep entriesNot set (keeps all)
Watcher-specific retentionOverride global setting per entry typeVaries by watcher

Expected Implementation Pattern


Prune Operation Flow


Sources: src/TelescopeServiceProvider.php100-107 src/Contracts/PrunableRepository.php


telescope:publish Command

The PublishCommand exports Telescope's package files to the application directory structure, allowing customization of migrations, assets, configuration, and service provider logic.

Publishable Asset Groups

The command supports tagged publishing, allowing selective export of different asset types:

TagSource PathTarget PathPurpose
telescope-migrationsdatabase/migrations/database/migrations/Database schema files
telescope-assetspublic/public/vendor/telescope/JavaScript and CSS files
telescope-configconfig/telescope.phpconfig/telescope.phpConfiguration file
telescope-providerstubs/TelescopeServiceProvider.stubapp/Providers/Customizable service provider

Publishing Registration

The publishable resources are registered in src/TelescopeServiceProvider.php76-93:


Publish Command Usage


Command Execution Examples


Sources: src/TelescopeServiceProvider.php76-93 src/Console/PublishCommand.php


Command Registration in Service Provider

The command registration process is straightforward and occurs early in the application bootstrap sequence, before conditional Telescope initialization:


Key Implementation Detail

Commands are registered unconditionally (line 25) before checking telescope.enabled (line 28). This design ensures that administrative commands like telescope:clear and telescope:publish remain available even when Telescope monitoring is disabled, allowing operators to manage existing data and export configuration.

Sources: src/TelescopeServiceProvider.php23-48 src/TelescopeServiceProvider.php98-107


Repository Contract Binding

Commands interact with storage through three repository contracts, all bound to DatabaseEntriesRepository by default:

Contract-to-Implementation Mapping

ContractMethodsUsed By CommandsBinding Location
ClearableRepositoryclear()telescope:clearsrc/TelescopeServiceProvider.php170-173
PrunableRepositoryprune(Carbon $before)telescope:prunesrc/TelescopeServiceProvider.php175-178
EntriesRepositorystore(), update(), etc.(Storage operations)src/TelescopeServiceProvider.php165-168

Binding Registration Flow


This binding pattern enables alternative storage implementations (e.g., Redis, Elasticsearch) by implementing the same contracts and registering different driver methods.

Sources: src/TelescopeServiceProvider.php151-179 src/Contracts/ClearableRepository.php src/Contracts/PrunableRepository.php src/Contracts/EntriesRepository.php