Skip to content

Commit

Permalink
added Laravel Telescope for local development
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen committed Oct 2, 2023
1 parent f839c71 commit dc8428c
Show file tree
Hide file tree
Showing 11 changed files with 385 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -390,6 +393,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -625,6 +631,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -860,6 +869,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -1095,6 +1107,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -1330,6 +1345,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -1565,6 +1583,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -1800,6 +1821,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -2035,6 +2059,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -2270,6 +2297,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down Expand Up @@ -2505,6 +2535,9 @@
'Illuminate\Session\Console\SessionTableCommand' => \Illuminate\Session\Console\SessionTableCommand::class,
'Illuminate\Session\Middleware\StartSession' => \Illuminate\Session\Middleware\StartSession::class,
'Illuminate\Testing\ParallelTesting' => \Illuminate\Testing\ParallelTesting::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\PrunableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Livewire\EventBus' => \Livewire\EventBus::class,
'Livewire\LivewireManager' => \Livewire\LivewireManager::class,
'Livewire\Mechanisms\ComponentRegistry' => \Livewire\Mechanisms\ComponentRegistry::class,
Expand Down
3 changes: 3 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public function register(): void
{
if ($this->app->isLocal()) {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);

$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
$this->app->register(TelescopeServiceProvider::class);
}
}

Expand Down
65 changes: 65 additions & 0 deletions app/Providers/TelescopeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;

class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
// Telescope::night();

$this->hideSensitiveRequestDetails();

Telescope::filter(function (IncomingEntry $entry) {
if ($this->app->environment('local')) {
return true;
}

return $entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}

/**
* Prevent sensitive request details from being logged by Telescope.
*/
protected function hideSensitiveRequestDetails(): void
{
if ($this->app->environment('local')) {
return;
}

Telescope::hideRequestParameters(['_token']);

Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}

/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*/
protected function gate(): void
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
//
]);
});
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"fakerphp/faker": "^1.23.0",
"laravel/pint": "^1.13.2",
"laravel/sail": "^1.25.0",
"laravel/telescope": "^4.16",
"mockery/mockery": "^1.6.6",
"nunomaduro/collision": "^7.9.0",
"phpunit/phpunit": "^10.3.5",
Expand Down Expand Up @@ -75,7 +76,8 @@
"extra": {
"laravel": {
"dont-discover": [
"barryvdh/laravel-ide-helper"
"barryvdh/laravel-ide-helper",
"laravel/telescope"
]
}
},
Expand Down
73 changes: 72 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dc8428c

Please sign in to comment.