定制 thyseus/filament-barstool 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thyseus/filament-barstool

Composer 安装命令:

composer require thyseus/filament-barstool

包简介

Filament resource for displaying Saloon Barstool API logs

README 文档

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

统计信息

  • 总下载量: 195
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固