PHPackages                             jiaojie/pop-data - 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. jiaojie/pop-data

ActiveLibrary

jiaojie/pop-data
================

Pop Data Component for Pop PHP Framework, This is a copy version.

2.1.0p2(8y ago)013New BSDPHPPHP &gt;=5.4.0

Since Jul 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jiaojie1989/pop-data)[ Packagist](https://packagist.org/packages/jiaojie/pop-data)[ Docs](http://www.popphp.org/)[ RSS](/packages/jiaojie-pop-data/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (11)Used By (0)

pop-data
========

[](#pop-data)

END OF LIFE
-----------

[](#end-of-life)

The `pop-data` component v2.1.0 is now end-of-life. The CSV sub-component has been forked and pushed into its own repository:

- popphp/pop-csv

[![Build Status](https://camo.githubusercontent.com/e03e4ba00bd9bc8c25d2df9143c176819f9a71c70f063865f1b845fb024dd527/68747470733a2f2f7472617669732d63692e6f72672f706f707068702f706f702d646174612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/popphp/pop-data)[![Coverage Status](https://camo.githubusercontent.com/010b95e0bad126331c4a9a34d8be4a9b3a9dcaa4f1b7587e47200e9629f800e3/687474703a2f2f63632e706f707068702e6f72672f636f7665726167652e7068703f636f6d703d706f702d64617461)](http://cc.popphp.org/pop-data/)

OVERVIEW
--------

[](#overview)

`pop-data` provides a streamlined way to convert common data types. With it, you can easily give it some native PHP data and quickly produce a serialized version of that data in a common data type, such as CSV, JSON, SQL, XML or YAML. Or, conversely, you can give it some serialized data, an it will auto-detect the format and convert it to native PHP data.

`pop-data`is a component of the [Pop PHP Framework](http://www.popphp.org/).

INSTALL
-------

[](#install)

Install `pop-data` using Composer.

```
composer require popphp/pop-data

```

BASIC USAGE
-----------

[](#basic-usage)

### Serialize Data

[](#serialize-data)

```
$phpData = [
    [
        'first_name' => 'Bob',
        'last_name'  => 'Smith'
    ],
    [
        'first_name' => 'Jane',
        'last_name'  => 'Smith'
    ]
];

$data = new Pop\Data\Data($phpData);

$csvString   = $data->serialize('csv');
$jsonString  = $data->serialize('json');
$sqlString   = $data->serialize('sql');
$xmlString   = $data->serialize('xml');
$yamlString  = $data->serialize('yaml');
```

The $csvString variable now contains:

```
first_name,last_name
Bob,Smith
Jane,Smith

```

The $jsonString variable now contains:

```
[
    {
        "first_name": "Bob",
        "last_name": "Smith"
    },
    {
        "first_name": "Jane",
        "last_name": "Smith"
    }
]

```

The $sqlString variable now contains:

```
INSERT INTO data (first_name, last_name) VALUES
('Bob', 'Smith'),
('Jane', 'Smith');

```

The $xmlString variable now contains:

```

    Bob
    Smith

    Jane
    Smith

```

The $yamlString variable now contains:

```
---
- first_name: Bob
  last_name: Smith
- first_name: Jane
  last_name: Smith
...

```

### Unserialize Data

[](#unserialize-data)

You can either pass the data object a direct string of serialized data or a file containing a string of serialized data. It will detect which one it is and parse it accordingly.

##### String

[](#string)

```
$csv     = new Pop\Data\Data($csvString);
$phpData = $csv->unserialize();
```

##### File

[](#file)

```
$xml     = new Pop\Data\Data('/path/to/file.xml');
$phpData = $xml->unserialize();
```

### Convert Between Data Types

[](#convert-between-data-types)

```
$csv = new Pop\Data\Data($csvString);
$xml = $csv->convert('xml');
```

### Write to File

[](#write-to-file)

```
$phpData = [ ... ];

$data = new Pop\Data\Data($phpData);
$data->serialize('csv');
$data->writeToFile('/path/to/file.csv');
```

### Output to HTTP

[](#output-to-http)

```
$phpData = [ ... ];

$data = new Pop\Data\Data($phpData);
$data->serialize('csv');
$data->outputToHttp();
```

##### Force download of file

[](#force-download-of-file)

```
$phpData = [ ... ];

$data = new Pop\Data\Data($phpData);
$data->serialize('csv');
$data->outputToHttp('my-file.csv', true);
```

Notice
======

[](#notice)

This copy is used as a legacy library.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% 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

Every ~82 days

Recently: every ~106 days

Total

10

Last Release

3209d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/603167de95d08f2a3edaf5acc3545be0e293566e84bddf4e9b5010aa0e52f6f3?d=identicon)[jiaojie1989](/maintainers/jiaojie1989)

---

Top Contributors

[![nicksagona](https://avatars.githubusercontent.com/u/898670?v=4)](https://github.com/nicksagona "nicksagona (39 commits)")[![jiaojie1989](https://avatars.githubusercontent.com/u/8794115?v=4)](https://github.com/jiaojie1989 "jiaojie1989 (3 commits)")

---

Tags

phppoppop phpdata-conversiondata convert

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jiaojie-pop-data/health.svg)

```
[![Health](https://phpackages.com/badges/jiaojie-pop-data/health.svg)](https://phpackages.com/packages/jiaojie-pop-data)
```

###  Alternatives

[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[popphp/pop-pdf

PHP PDF library for generating and importing PDF documents. A component of the Pop PHP Framework

207.8k1](/packages/popphp-pop-pdf)[popphp/pop-http

Pop Http Component for Pop PHP Framework

1018.5k13](/packages/popphp-pop-http)

PHPackages © 2026

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