trendyminds / craft-reporter
一键导出Craft数据为CSV文件
2.3.0
2024-04-10 14:40 UTC
Requires
- php: >=8.0.2
- craftcms/cms: ^4.0.0
- league/fractal: ^0.20.1
Requires (Dev)
- laravel/pint: ^1.10
This package is auto-updated.
Last update: 2024-09-10 15:33:59 UTC
README
📊 一键导出Craft数据为CSV文件!
⚡️ 功能
- 🏎 报告通过查询批量处理进行处理,使导出运行快速且不会耗尽您的内存限制
- 🧘 受Element API启发,以简单熟悉的结构创建报告
- 📦 报告使用资产卷存储,您可以在本地或Amazon S3等基于云的服务上托管报告
- 🖥 使用
php craft reporter/report --handle=myReport
通过CLI处理报告,其中myReport
是位于config/reporter.php
中的reports
数组中特定报告的键。
📦 安装
以两种方式之一安装Reporter
- 通过Craft的插件商店安装
- 运行
composer require trendyminds/craft-reporter
,然后在"设置 > 插件"中启用插件
🔌 设置
要设置报告,在config/
中创建一个reporter.php
文件。下面是一个示例配置文件。
示例配置
<?php use craft\elements\Entry; use craft\elements\Asset; return [ // The name to use throughout the control panel (defaults to "Reporter") 'displayName' => 'Reports', // The asset volume handle where your reports should be saved // NOTE: Your reports are publicly accessible if your volume has "Assets in this volume have public URLs" enabled 'volume' => 'uploads', // An optional folder path if you would like to nest the reports in a specific directory 'folder' => 'resources/reports', // An optional batch size to use when processing reports (defaults to 100) 'batchSize' => 100, // An array of reports to produce 'reports' => [ 'pages' => function () { return [ 'name' => 'All Pages', 'description' => 'A simple export of all the pages on the site.', 'elementType' => Entry::class, 'criteria' => [ 'section' => 'pages' ], 'transformer' => function (Entry $entry) { return [ "id" => $entry->id, "title" => $entry->title, "url" => $entry->url, ]; } ]; }, 'allImages' => function () { return [ 'name' => 'Uploaded Images', 'description' => 'A list of all images uploaded into Craft', 'elementType' => Asset::class, 'criteria' => [ 'kind' => 'image' ], 'transformer' => function (Asset $asset) { // Skip example // Ignore assets that have an even number for an ID if ($asset->id % 2 === 0) { return []; } return [ "id" => $asset->id, "title" => $asset->title, "filename" => $asset->filename, ]; } ]; }, ] ];
🤝 贡献
如果您想为Reporter做出贡献,我们尽量让它变得尽可能简单
- 克隆仓库
- 运行
npm i
以安装Node依赖 - 运行
npm start
以开始监视任务 - 做出您的更改
- 运行
npm run build
以编译和压缩CSS和JS - 提交PR!