PHPackages                             frictionlessdata/datapackage - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. frictionlessdata/datapackage

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

frictionlessdata/datapackage
============================

A utility library for working with Data Packages

v1.0.0(4y ago)102.6k↓50%10[12 issues](https://github.com/frictionlessdata/datapackage-php/issues)[1 PRs](https://github.com/frictionlessdata/datapackage-php/pulls)1MITPHPPHP &gt;=7.1CI failing

Since Apr 17Pushed 3mo ago7 watchersCompare

[ Source](https://github.com/frictionlessdata/datapackage-php)[ Packagist](https://packagist.org/packages/frictionlessdata/datapackage)[ RSS](/packages/frictionlessdata-datapackage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (6)Versions (11)Used By (1)

Data Package
============

[](#data-package)

[![Build](https://github.com/frictionlessdata/datapackage-php/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/frictionlessdata/datapackage-php/actions/workflows/ci.yml)[![Coveralls](https://camo.githubusercontent.com/699809a3321326f0a013c5135fe899be580a8cecab259d870ed01ea91dcbb7ba/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6672696374696f6e6c657373646174612f646174617061636b6167652d7068702e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/frictionlessdata/datapackage-php?branch=master)[![Scrutinizer-ci](https://camo.githubusercontent.com/ff5290dc19671450888a968e60130d011742f3ec17b45c4c6b507af6d36e0a73/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6672696374696f6e6c657373646174612f646174617061636b6167652d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/frictionlessdata/datapackage-php/)[![Packagist](https://camo.githubusercontent.com/668b4115100b7b85f931c96ca98a50f8ae4c2cd9e21f580ef52d0c1cb37d86af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6672696374696f6e6c657373646174612f646174617061636b6167652e737667)](https://packagist.org/packages/frictionlessdata/datapackage)[![SemVer](https://camo.githubusercontent.com/45f93e2041a390dd2ac2b65c9d8a30d49c5bcb1daba2a4cb9b761ce1b57da332/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e732d53656d5665722d627269676874677265656e2e737667)](http://semver.org/)[![Codebase](https://camo.githubusercontent.com/78247530a35f3bb28ca0dfe54db1e072372948cea17e1dc02b8e8a8219afe4bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6465626173652d6769746875622d627269676874677265656e)](https://github.com/frictionlessdata/datapackage-php)[![Support](https://camo.githubusercontent.com/4daae5075cff697eaeeee7ece1f29ad900e1f015452da0316a897466c3788a35/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742d646973636f72642d627269676874677265656e)](https://discordapp.com/invite/Sewv6av)

A utility library for working with [Data Package](https://specs.frictionlessdata.io/data-package/) in PHP.

Features summary and Usage guide
--------------------------------

[](#features-summary-and-usage-guide)

### Installation

[](#installation)

```
composer require frictionlessdata/datapackage
```

Optionally, to create zip files you will need the PHP zip extension. On Ubuntu it can be enabled with `sudo apt-get install php-zip`

### Package

[](#package)

Load a data package conforming to the specs

```
use frictionlessdata\datapackage\Package;
$package = Package::load("tests/fixtures/multi_data_datapackage.json");
```

Iterate over the resources and the data

```
foreach ($package as $resource) {
    echo $resource->name();
    foreach ($resource as $row) {
        echo $row;
    }
}
```

Get all the data as an array (loads all the data into memory, not recommended for large data sets)

```
foreach ($package as $resource) {
    var_dump($resource->read());
}
```

All data and schemas are validated and throws exceptions in case of any problems.

Validate the data explicitly and get a list of errors

```
Package::validate("tests/fixtures/simple_invalid_datapackage.json");  // array of validation errors
```

Load a zip file

```
$package = Package::load('http://datahub.io/opendatafortaxjustice/eucountrydatawb/r/datapackage_zip.zip');
```

Provide read options which are passed through to [tableschema-php](https://github.com/frictionlessdata/tableschema-php) Table::read method

```
$package = Package::load('http://datahub.io/opendatafortaxjustice/eucountrydatawb/r/datapackage_zip.zip');
foreach ($package as $resource) {
    $resource->read(["cast" => false]);
}
```

The package object has some useful methods to access and manipulate the resources

```
$package = Package::load("tests/fixtures/multi_data_datapackage.json");
$package->resources();  // array of resource name => Resource object (see below for Resource class reference)
$package->getResource("first-resource");  // Resource object matching the given name
$package->removeResource("first-resource");
// add a tabular resource
$package->addResource("tabular-resource-name", [
    "profile" => "tabular-data-resource",
    "schema" => [
        "fields" => [
            ["name" => "id", "type" => "integer"],
            ["name" => "name", "type" => "string"]
        ]
    ],
    "path" => [
        "tests/fixtures/simple_tabular_data.csv",
    ]
]);
```

Create a new package from scratch

```
$package = Package::create([
    "name" => "datapackage-name",
    "profile" => "tabular-data-package"
]);
// add a resource
$package->addResource("resource-name", [
    "profile" => "tabular-data-resource",
    "schema" => [
        "fields" => [
            ["name" => "id", "type" => "integer"],
            ["name" => "name", "type" => "string"]
        ]
    ],
    "path" => "tests/fixtures/simple_tabular_data.csv"
]);
// save the package descriptor to a file
$package->saveDescriptor("datapackage.json");
```

Save the entire datapackage including any local data to a zip file

```
$package->save("datapackage.zip");
```

### Resource

[](#resource)

Resource objects can be accessed from a Package as described above

```
$resource = $package->getResource("resource-name")
```

or instantiated directly

```
use frictionlessdata\datapackage\Resource;
$resource = Resource::create([
    "name" => "my-resource",
    "profile" => "tabular-data-resource",
    "path" => "tests/fixtures/simple_tabular_data.csv",
    "schema" => ["fields" => [["name" => "id", "type" => "integer"], ["name" => "name", "type" => "string"]]]
]);
```

Iterating or reading over the resource produces combined rows from all the path or data elements

```
foreach ($resource as $row) {};  // iterating
$resource->read();  // get all the data as an array
```

Contributing
------------

[](#contributing)

Please read the contribution guidelines: [How to Contribute](CONTRIBUTING.md)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 51.5% 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 ~199 days

Recently: every ~372 days

Total

9

Last Release

1723d ago

Major Versions

v0.1.9 → v1.0.02021-08-29

PHP version history (3 changes)v0.1.0PHP &gt;=5.4

v0.1.9PHP &gt;=5.6

v1.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/33b6bb5c2a2ef2cf758cb86705891b08d72d74e083a593fd057de4345d17a312?d=identicon)[OriHoch](/maintainers/OriHoch)

![](https://www.gravatar.com/avatar/a32730de9fb7d601730c3149bd533322afe34bbcd1aa53be6985cdece21ae65e?d=identicon)[courtney-miles](/maintainers/courtney-miles)

---

Top Contributors

[![OriHoch](https://avatars.githubusercontent.com/u/1198854?v=4)](https://github.com/OriHoch "OriHoch (35 commits)")[![DiegoPino](https://avatars.githubusercontent.com/u/6946023?v=4)](https://github.com/DiegoPino "DiegoPino (16 commits)")[![roll](https://avatars.githubusercontent.com/u/557395?v=4)](https://github.com/roll "roll (9 commits)")[![jonrmitchell](https://avatars.githubusercontent.com/u/492582?v=4)](https://github.com/jonrmitchell "jonrmitchell (3 commits)")[![pwalsh](https://avatars.githubusercontent.com/u/791678?v=4)](https://github.com/pwalsh "pwalsh (3 commits)")[![dpritchard](https://avatars.githubusercontent.com/u/358971?v=4)](https://github.com/dpritchard "dpritchard (1 commits)")[![aphofstede](https://avatars.githubusercontent.com/u/701218?v=4)](https://github.com/aphofstede "aphofstede (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/frictionlessdata-datapackage/health.svg)

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[getdkan/dkan

DKAN Open Data Catalog

385135.4k2](/packages/getdkan-dkan)[e0ipso/shaper

Lightweight library to handle in and out transformations in PHP.

157.8M4](/packages/e0ipso-shaper)[nfephp-org/sped-esocial

e-Social library

18030.7k](/packages/nfephp-org-sped-esocial)[optimizely/optimizely-sdk

Optimizely PHP SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts

191.8M1](/packages/optimizely-optimizely-sdk)

PHPackages © 2026

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