3neti/report-registry
Composer 安装命令:
composer require 3neti/report-registry
包简介
Driver-based report registry with multi-format output and Handlebars templating
README 文档
README
Report Registry and Execution Engine for Laravel
Overview
3neti/report-registry is a Laravel package for defining, discovering, executing, and rendering reports using YAML-based drivers.
It provides:
- Driver-based report definitions (YAML)
- Resolver-driven data execution
- Pluggable output formatters (JSON, HTML, CSV, Text)
- Clean separation between data resolution and rendering
Key Concepts
Report Driver
A YAML file that defines:
- metadata (id, title, description)
- columns
- filters
- resolver class
- optional templates
Resolver
A class that implements:
ReportResolverInterface
Responsible for fetching and returning report data.
Executor
ReportExecutor orchestrates:
- loading the driver
- executing the resolver
- returning either raw data or formatted output
Output Modes
The executor supports two output categories:
1. Raw (machine-readable)
Returns structured PHP array:
$result = $executor->execute('sales', format: 'raw');
Structure:
[ 'report' => [...], 'data' => [...], 'meta' => [...] ]
2. Rendered (string output)
Formats:
jsonhtmlcsvtext
$json = $executor->execute('sales', format: 'json'); $html = $executor->execute('sales', format: 'html');
All return strings.
Example Usage
$executor = app(ReportExecutor::class); // Raw payload $data = $executor->execute('sales', format: 'raw'); // JSON output $json = $executor->execute('sales', format: 'json'); // HTML output $html = $executor->execute('sales', format: 'html');
Resolver Example
class SalesReportResolver implements ReportResolverInterface { public function resolve( array $filters = [], ?string $sort = null, string $sortDirection = 'desc', int $perPage = 10, int $page = 1, ): array { return [ 'data' => [ [ 'reference' => 'INV-001', 'amount' => 1250.50, 'status' => 'approved', ] ], 'meta' => [ 'total' => 1, 'page' => 1, 'per_page' => $perPage, ], ]; } }
CLI Usage
php artisan report:run sales --format=json php artisan report:run sales --format=html php artisan report:run sales --format=raw
Options:
--filter=status:approved--sort=created_at--sort-dir=asc--per-page=50--page=1--output=report.json
Formatter Contract
All formatters implement:
ReportFormatterInterface
public function format(ReportDriverData $driver, array $data, array $meta): string;
Built-in formatters:
- JSON
- HTML
- CSV
- Text
Driver Structure (YAML)
driver: id: sales version: 1.1.0 title: Sales Report columns: - key: reference label: Reference - key: amount label: Amount resolver: App\Reports\SalesReportResolver
Design Principles
- Separation of concerns
- Resolver = data
- Formatter = output
- Driver-driven architecture
- Extensible format system
- API-first execution model
Testing
Run tests:
composer test
Coverage includes:
- driver loading
- version resolution
- execution
- formatting
- output contracts
License
MIT
3neti/report-registry 适用场景与选型建议
3neti/report-registry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 3neti/report-registry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 3neti/report-registry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-26