Skip to content

Easily add Laravel Telescope and Horizon to Filament admin panel.

License

Notifications You must be signed in to change notification settings

G3z/filament-debugger

 
 

Repository files navigation

Filament Debugger

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

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',
    ],
];

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.

About

Easily add Laravel Telescope and Horizon to Filament admin panel.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%