stephenjude / filament-debugger
About
Installs: 10 409
Dependents: 0
Suggesters: 0
Security: 0
Stars: 52
Watchers: 4
Forks: 11
Open Issues: 1
Requires
- php: ^8.1
- filament/filament: ^3.0
- laravel/horizon: ^5.21
- laravel/telescope: ^4.16|^5.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- laravel/pint: ^1.13
- nunomaduro/collision: ^5.11|^6.4|^7.0|^8.0
- orchestra/testbench: ^6.0|^7.0|^8.0|^9.0
- pestphp/pest: ^1.4|^2.24
- pestphp/pest-plugin-laravel: ^1.22|^2.2
- phpunit/phpunit: ^9.0|^10.0
README
Easily add Laravel Telescope and Horizon to Filament admin panel.
Installation
You can install the package via composer:
composer require stephenjude/filament-debugger
Run the setup command using
php artisan filament-debugger:install
This is the contents of the published config file:
return [ 'debuggers' => [ 'horizon', 'telescope' ], 'authorization' => false, 'permissions' => [ 'horizon' => 'horizon.view', 'telescope' => 'telescope.view', ], ];
Add the plugin to your panel plugins array
$panel ->plugins([ DebuggerPlugin::make(), ]);
Debuggers
This package comes with first party Laravel packages for development and monitoring your Laravel application.
Laravel Telescope
Telescope provides insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, variable dumps, and more. Documentation.
Laravel Horizon
Horizon allows you to easily monitor key metrics of your queue system such as job throughput, runtime, and job failures. Documentation.
Usage
Now you can view the installed debuggers when you log in into your filament admin panel.
Gates & Authorization
When using filament debuggers (Horizon & Telescope) in production environment, we need to make sure that they are accessible to the authorized filament admin user.
To achive this, we need to use filament default authorization guard and the permissions provided in this package by overidding the gate()
and authorization()
methods inside the HorizonServiceProvider and TelescopeServiceProvider respectively.
Navigation Access
We need to set authorization to true
inside the filament debugger config if we want to make it visible to only users with correct access in the admin panel navigation.
Update HorizonServiceProvider.php
protected function gate() { Gate::define('viewHorizon', function ($user) { return $user->can(config('filament-debugger.permissions.horizon')); }); } protected function authorization() { Auth::setDefaultDriver(config('filament.auth.guard')); parent::authorization(); }
Update TelescopeServiceProvider.php
protected function gate() { Gate::define('viewTelescope', function ($user) { return $user->can(config('filament-debugger.permissions.telescope')); }); } protected function authorization() { Auth::setDefaultDriver(config('filament.auth.guard')); parent::authorization(); }
Creating Permissions
To make use of the permissions configured in this package we need a permission package like Laravel Permissions or Bouncer which usually comes with the Permission
Model. USe what works for you.
The permissions we need to create is already defined inside the filament debugger config file.
Here is an example using the Spatie Permission Package:
use Spatie\Permission\Models\Permission; collect(config('filament-debugger.permissions')) ->map(fn($permission) => Permission::firstOrCreate([ 'name' => $permission, 'guard_name' => config('filament.auth.guard'), ]));
You can also use your already created permission by updating the permission configuration:
'permissions' => [ 'horizon' => 'your horizon permission name', 'telescope' => 'your telescope permission name', ],
Screenshots:
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.