paxal/stats-table
Composer 安装命令:
composer require paxal/stats-table
包简介
Helper to handle stats table with multiple formatter
README 文档
README
This package is a fork of igraal/stats-table
stats-table
PHP Libary to handle statistics tables and CSV, JSON and Excel exports.
Summary
This library helps you create statistical tables given some data. You provide data, headers and what you want for the footer line, and then you can dump your table into a JSON, CSV or Excel file.
This is very useful to manipulate a lot of tables you want to see in an HTML FrontOffice and when you want to add the ability to get this data in CSV or Excel File as well.
Installation
Using composer
Using composer, just run the following to require the latest stable :
composer req paxal/stats-table
Usage
Using the class StatsTable
The class StatsTable is the class that will hold your data. It takes one mandotary arguments, and 4 options arguments. The simpler way to create a new table is to pass the data itself and its headers (even if headers are optional).
use IgraalOSL\StatsTable\StatsTable; $data = [ ['date' => '2014-01-01', 'hits' => 32500], ['date' => '2014-01-02', 'hits' => 48650], ]; $headers = ['date' => 'Date', 'hits' => 'Number of hits']; $statsTable = new StatsTable($data, $headers);
Dumping a table
Three formats are currently supported : Excel, CSV and JSON. Thus, you can use the same table with your ajax calls or to be downloaded.
First, create your dumper, then dump your data.
use IgraalOSL\StatsTable\Dumper\Excel\ExcelDumper; $excelDumper = new ExcelDumper(); $excelContents = $excelDumper->dump($statsTable); header('Content-type: application/vnd.ms-excel'); echo $excelContents
Using stats table builder
To help you construct a table, you can use the StatsTableBuilder class. It helps you combine data from multiple tables, and can create automatic calculated columns. It also helps you build aggregations (aka the footer line), with multiple possibilities : ratio, sum, average or static content.
use IgraalOSL\StatsTable\StatsTableBuilder; $data = [ '2014-01-01' => ['hits' => 32500], '2014-01-02' => ['hits' => 48650], ]; $statsTableBuilder = new StatsTableBuilder( $data, ['hits' => 'Number of hits'] ); $statsTableBuilder->addIndexesAsColumn('date', 'Date'); $statsTable = $statsTableBuilder->build();
paxal/stats-table 适用场景与选型建议
paxal/stats-table 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81.36k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「json」 「excel」 「xls」 「csv」 「stats」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 paxal/stats-table 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 paxal/stats-table 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 paxal/stats-table 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
Yii2 export extension
统计信息
- 总下载量: 81.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-17