承接 metin/exodus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

metin/exodus

最新稳定版本:0.3.0

Composer 安装命令:

composer require metin/exodus

包简介

Simple and flexible data export library for PHP

README 文档

README

Simple and flexible data export library for PHP.

$exporter = new ExportManager(new CsvExporter());
$options = new ExportOptions(
    path: '/path/to/export',
    delimiter: ',',
    includeHeaders: true
);
$result = $exporter->process($data, $options);

Installation

You can install the package via composer:

composer require metin/exodus

Requirements

  • PHP 8.2 or higher
  • ext-json
  • ext-fileinfo
  • ext-mbstring

Basic Usage

CSV Export

use Metin\Exodus\Core\ExportManager;
use Metin\Exodus\Exporters\CsvExporter;
use Metin\Exodus\Dto\ExportOptions;
// Prepare data
$data = [
    ['name' => 'John Doe', 'email' => 'john@example.com'],
    ['name' => 'Jane Doe', 'email' => 'jane@example.com']
];
// Configure export options
$options = new ExportOptions(
    path: '/path/to/export',
    delimiter: ',',
    includeHeaders: true,
    filename: 'users.csv'
);
// Create exporter and process
$exporter = new ExportManager(new CsvExporter());
$result = $exporter->process($data, $options);
if ($result->success) {
    echo "File exported to: " . $result->path;
} else {
    echo "Export failed: " . $result->error;
}

JSON Export

use Metin\Exodus\Core\ExportManager;
use Metin\Exodus\Exporters\JsonExporter;
use Metin\Exodus\Dto\ExportOptions;

// Prepare data
$data = [
    ['name' => 'John Doe', 'email' => 'john@example.com'],
    ['name' => 'Jane Doe', 'email' => 'jane@example.com']
];

// Configure export options
$options = new ExportOptions(
    path: '/path/to/export',
    filename: 'users.json',
    formatOptions: [
        'prettyPrint' => true,
        'unescapeUnicode' => true
    ]
);

// Create exporter and process
$exporter = new ExportManager(new JsonExporter());
$result = $exporter->process($data, $options);

if ($result->success) {
    echo "File exported to: " . $result->path;
} else {
    echo "Export failed: " . $result->error;
}

Features

  • Export data to multiple formats (CSV, JSON)
  • Format specific options support
  • CSV Features:
    • Configurable delimiter
    • Optional headers
  • JSON Features:
    • Pretty print option
    • Unicode character support
  • Comprehensive error handling
  • Data validation
  • Type-safe objects

Testing

The package comes with a PHPUnit test suite. To run the tests:

composer test

Test Directory Structure

tests/
├── TestCase.php              # Base test case with helper methods
├── Dto/                      # Tests for Data Transfer Objects
├── Exporters/               # Tests for Export implementations
└── data/                    # Test data directory (auto-created)

Testing Different Scenarios

The test suite covers:

  • CSV export with/without headers
  • Custom delimiters
  • Auto-generated and custom filenames
  • Error scenarios (invalid directory, empty data, etc.)
  • Data validation

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固