mixpo/form-data-exporter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mixpo/form-data-exporter

Composer 安装命令:

composer require mixpo/form-data-exporter

包简介

Simple Export Db -> CSV library

README 文档

README

A somewhat specific tool meant to export to CSV, a JSON data column for all rows in a SQL result set.

Status

Build Status

Coverage Status

Install

composer install

phpunit

Usage

<?php

$exporter = new FormExporter(
    'dsn', // <- PDO DSN string including credentials
    'tableName', // <- the table the you wish to export data from
    'data', // <- the name of the 'data' column (column that hold the JSON form data)
    ["client_id" => "12345", "campaign" => "widget-2015"], // <- criteria used to build an AND'ed WHERE clause
    $logger // <- Psr\Log\LoggerInterface
);

You then set the writer engine (file system and S3 are currently supported and run the export

$exporter->setExporterEngine(
    new FileSystemExporterEngine(
       'file:///var/data/csv/leadgen99.csv',  // <- full path to the output CSV in <protocol>://<path> format
                                                    s3://<bucket>/<object-path> is also supported
        $logger, // <- Psr\Log\LoggerInterface
        $randomizeFileName = true
    )
);
                                              
$outputCsvFilePath = $exporter->run();

NOTE In the example above the $outputCsvFilePath will have a random seed in it. For instance with file:///var/data/csv/leadgen99.csv sent into the ExporterEngine constructor, $outputCsvFilePath will be something like: /var/data/csv/leadgen99-55358afdeefa5.csv

To turn off this behavior call set $randomizeFileName = false

Rows with Issues

After calling $exporter->run(), you can call getIssues() which will return an array of any rows that had parse issues and will not be in the CSV output.

<?php

$exporter->run();
$issues = $exporter->getIssues();

/**
 * $issues will be an empty array if there were no issues, but if there were it will look something like this.
 *      [
 *       [
 *         "message" => "Expected data field of name: 'form_data', not found for this row",
 *         "row" => ["id" => 2, 
 *                   "identifier" => "client-xyz",
 *                   "tag" => "widget-1-campaign",
 *                   "version" => 1,
 *                   "created" => "2015-04-16 21:50:39"]
 *       ],
 *       ...
 *      ]
 **/

mixpo/form-data-exporter 适用场景与选型建议

mixpo/form-data-exporter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.4k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mixpo/form-data-exporter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mixpo/form-data-exporter 我们能提供哪些服务?
定制开发 / 二次开发

基于 mixpo/form-data-exporter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-21