thyseus / filament-barstool
Filament resource for displaying Saloon Barstool API logs
Package info
gitlab.com/thyseus/filament-barstool
Type:laravel-package
pkg:composer/thyseus/filament-barstool
Requires
- php: ^8.3
- filament/filament: ^4.0|^5.0
- laravel/framework: ^11.0|^12.0|^13.0
- saloonphp/barstool: ^1.0
Requires (Dev)
- pestphp/pest: ^4
README
Filament resource for displaying Saloon Barstool(https://github.com/saloonphp/barstool) API logs.
Important: By default, the resource is only visible in local environments. You should configure access control for your project immediately after installation (see Access Control section).
Requirements
- PHP 8.3+
- Laravel 11.0+|12.0+|13.0+
- Filament 4.0+|5.0+
- Saloon Barstool 1.0+
Installation
composer require thyseus/filament-barstool
Usage
The package provides a BarstoolResource that registers automatically when the service provider is loaded.
Access Control (higly recommended)
By default, the resource is only visible in local environments. You can customize this by calling the access() method:
use Thyseus\FilamentBarstool\BarstoolResource;
BarstoolResource::access(fn () => auth()->user()->hasPermission('view-barstool-logs'));
// or:
BarstoolResource::access(fn () => auth()->user()->email === 'admin@example.com');
Registration
Add to your Filament panel in a service provider:
use Filament\Filament;
use Filament\Plugins\Plugin;
use Thyseus\FilamentBarstool\BarstoolResource;
Filament::configureServingPlugins(function () {
BarstoolResource::class;
});
Or register manually in your panel:
use Thyseus\FilamentBarstool\BarstoolResource;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->resources([
BarstoolResource::class,
]);
}
}
Pruning Old Entries (recommended)
Barstool entries accumulate in your database. It is recommended to prune entries older than a certain number of days. Add a scheduled task to your bootstrap/app.php:
use Saloon\Barstool\Models\Barstool;
$schedule
->call(function (): void {
Barstool::query()
->where('created_at', '<=', now()->subDays(14))
->delete();
})
->dailyAt('02:15')
->description('Prune barstool entries older than 14 days');
Adjust the retention period (subDays(14)) and schedule frequency to your needs.
Features
- List view with sortable columns (timestamp, URL, method, status, duration)
- Response body preview in collapsed panel
- View action with modal showing full response headers/body in JSON format
- Read-only (no create, edit, or delete)
- Disabled global search
- Navigation label: "Saloon Logs"
Customization
Table Configuration
Extend BarstoolTable to customize the list table:
use Thyseus\FilamentBarstool\Tables\BarstoolTable;
BarstoolTable::configure($table)
// add custom configuration
Resource Customization
Extend the resource class to override settings:
use Thyseus\FilamentBarstool\BarstoolResource;
class CustomBarstoolResource extends BarstoolResource
{
protected static ?string $navigationLabel = 'API Logs';
protected static bool $isGloballySearchable = true;
}
Testing
The package includes an example test file at tests/BarstoolResourceTest.php. After installing the package, you can manually copy this file to your project's test directory if you need to run tests locally:
# Copy the test file to your project's tests directory
cp vendor/thyseus/filament-barstool/tests/BarstoolResourceTest.php tests/Feature/BarstoolResourceTest.php
Note: You may need to adjust the test imports (e.g., user model, permissions) to match your project's authentication setup.
Note about AI usage
This package is "vise"-coded: Supervised by a human, but mostly generated by an LLM. I have personally reviewed every line of code, and would have created everything by hand exactly so, just much slower. I use this package in production.
License
MIT