pvessel/table-converter-bundle

此包提供了一种灵活的工具,用于在不同格式之间转换表格数据。

dev-master 2014-04-17 20:50 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:13:31 UTC


README

这个简单的包提供了一种灵活的工具,用于在不同格式之间转换表格数据。例如

以json编写的数组可以转换为csv字符串,或者HTML表格可以转换为XML字符串。

它使用内置和外部“导入器”(解析源字符串)和“导出器”(生成目标字符串)。

安装

步骤 1:使用composer下载PvesselTableConverterBundle

通过运行以下命令告诉composer需要PvesselTableConverterBundle

$ php composer.phar require "pvessel/table-converter-bundle:dev-master"

composer会将此包安装到项目的vendor/pvessel/table-converter-bundle目录。

步骤 2:启用包

最后,在kernel中启用该包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...

        new Pvessel\TableConverterBundle\PvesselTableConverterBundle(),
    );
}

配置

此包作为服务运行。这意味着你只需要

$convertedTable = $this->container->get('pvessel_table_converter.manager')
                                  ->setSource($sourceTable)
                                  ->convert($importerAlias, $exporterAlias)
                                  ->getTarget();

导入器和导出器

为了运行,包需要导入器和导出器。内置了一些

  • json
  • xml
  • html_table
  • html_ul
  • ascii_table
  • csv

请参阅文档以获取更多信息。