Skip to content

Commit 72f9370

Browse files
committed
Added Telescope + Horizon
1 parent 9370a8e commit 72f9370

20 files changed

+1585
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\Facades\Gate;
6+
use Laravel\Horizon\Horizon;
7+
use Laravel\Horizon\HorizonApplicationServiceProvider;
8+
9+
class HorizonServiceProvider extends HorizonApplicationServiceProvider
10+
{
11+
/**
12+
* Bootstrap any application services.
13+
*/
14+
public function boot(): void
15+
{
16+
parent::boot();
17+
18+
// Horizon::routeSmsNotificationsTo('15556667777');
19+
// Horizon::routeMailNotificationsTo('example@example.com');
20+
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
21+
22+
// Horizon::night();
23+
}
24+
25+
/**
26+
* Register the Horizon gate.
27+
*
28+
* This gate determines who can access Horizon in non-local environments.
29+
*/
30+
protected function gate(): void
31+
{
32+
Gate::define('viewHorizon', function ($user) {
33+
return in_array($user->email, [
34+
//
35+
]);
36+
});
37+
}
38+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\Facades\Gate;
6+
use Laravel\Telescope\IncomingEntry;
7+
use Laravel\Telescope\Telescope;
8+
use Laravel\Telescope\TelescopeApplicationServiceProvider;
9+
10+
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
11+
{
12+
/**
13+
* Register any application services.
14+
*/
15+
public function register(): void
16+
{
17+
// Telescope::night();
18+
19+
$this->hideSensitiveRequestDetails();
20+
21+
Telescope::filter(function (IncomingEntry $entry) {
22+
if ($this->app->environment('local')) {
23+
return true;
24+
}
25+
26+
return $entry->isReportableException() ||
27+
$entry->isFailedRequest() ||
28+
$entry->isFailedJob() ||
29+
$entry->isScheduledTask() ||
30+
$entry->hasMonitoredTag();
31+
});
32+
}
33+
34+
/**
35+
* Prevent sensitive request details from being logged by Telescope.
36+
*/
37+
protected function hideSensitiveRequestDetails(): void
38+
{
39+
if ($this->app->environment('local')) {
40+
return;
41+
}
42+
43+
Telescope::hideRequestParameters(['_token']);
44+
45+
Telescope::hideRequestHeaders([
46+
'cookie',
47+
'x-csrf-token',
48+
'x-xsrf-token',
49+
]);
50+
}
51+
52+
/**
53+
* Register the Telescope gate.
54+
*
55+
* This gate determines who can access Telescope in non-local environments.
56+
*/
57+
protected function gate(): void
58+
{
59+
Gate::define('viewTelescope', function ($user) {
60+
return in_array($user->email, [
61+
//
62+
]);
63+
});
64+
}
65+
}

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"php": "^8.1",
99
"guzzlehttp/guzzle": "^7.2",
1010
"laravel/framework": "^10.0",
11+
"laravel/horizon": "^5.15",
1112
"laravel/sanctum": "^3.2",
13+
"laravel/telescope": "^4.14",
1214
"laravel/tinker": "^2.8"
1315
},
1416
"require-dev": {

composer.lock

Lines changed: 150 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@
193193
App\Providers\AuthServiceProvider::class,
194194
// App\Providers\BroadcastServiceProvider::class,
195195
App\Providers\EventServiceProvider::class,
196+
App\Providers\HorizonServiceProvider::class,
196197
App\Providers\RouteServiceProvider::class,
198+
App\Providers\TelescopeServiceProvider::class,
197199

198200
],
199201

0 commit comments

Comments
 (0)