PHPackages                             wujiangweiphp/yieldcsv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. wujiangweiphp/yieldcsv

ActiveLibrary[File &amp; Storage](/categories/file-storage)

wujiangweiphp/yieldcsv
======================

php use yield export huge csv

v1.0(7y ago)6183MITPHPPHP &gt;=5.5

Since Jan 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/wujiangweiphp/yieldcsv)[ Packagist](https://packagist.org/packages/wujiangweiphp/yieldcsv)[ RSS](/packages/wujiangweiphp-yieldcsv/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

### 本例程是关于大量数据以csv格式导出时使用`yield`关键字减少内存使用的示例

[](#本例程是关于大量数据以csv格式导出时使用yield关键字减少内存使用的示例)

### 1. 使用前提

[](#1-使用前提)

> php &gt;= 5.5

### 2. 使用方法

[](#2-使用方法)

> step1 实例化YieldCsv

```
$yieldCsv = new YieldCsv();
```

> step2 查询数据

#### 2.1 根据文件导入数据

[](#21-根据文件导入数据)

```
$query_info = array(
       'file_name'=>'your file path',
       'fields'=> array(
               'id' => '编号',
               'nickname' => '昵称',
               'age' => '年龄',
               'desc' => '简介'
            )
       );
$data = $yieldCsv->getFileData($query_info,1);
foreach($data as $k => $v){
    // your oper to insert to mysql
}
```

#### 2.2 根据数据库导出csv文件

[](#22--根据数据库导出csv文件)

```
$query_info = array(
       'connect_config' => array(
           'host' => 127.0.0.1,
           'dbname' => 'test',
           'username' => 'www',
           'password' => '123456'
       ),
       'query' => 'select id,nickname,age,desc from user ',
       'fields'=> array(
               'id' => '编号',
               'nickname' => '昵称',
               'age' => '年龄',
               'desc' => '简介'
            )
       );
$yieldCsv->exportCsv($query_info,2);
```

#### 2.2 根据数据库查询

[](#22--根据数据库查询)

```
$query_info = array(
       'connect_config' => array(
           'host' => 127.0.0.1,
           'dbname' => 'test',
           'username' => 'www',
           'password' => '123456'
       ),
       'query' => 'select id,nickname,age,desc from user ',
       'fields'=> array(
               'id' => '编号',
               'nickname' => '昵称',
               'age' => '年龄',
               'desc' => '简介'
            )
       );
$data = $yieldCsv->getFileData($query_info,2);
foreach($data as $k => $v){
    // your oper code
}
```

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2775d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9715745?v=4)[wujiangweiphp](/maintainers/wujiangweiphp)[@wujiangweiphp](https://github.com/wujiangweiphp)

---

Top Contributors

[![wujiangweiphp](https://avatars.githubusercontent.com/u/9715745?v=4)](https://github.com/wujiangweiphp "wujiangweiphp (3 commits)")

### Embed Badge

![Health badge](/badges/wujiangweiphp-yieldcsv/health.svg)

```
[![Health](https://phpackages.com/badges/wujiangweiphp-yieldcsv/health.svg)](https://phpackages.com/packages/wujiangweiphp-yieldcsv)
```

###  Alternatives

[qcloud/cos-sdk-v5

PHP SDK for QCloud COS

1931.6M155](/packages/qcloud-cos-sdk-v5)[wikimedia/relpath

Work with file paths to join or find the relative path

11948.9k4](/packages/wikimedia-relpath)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
