PHPackages                             jjware/phpcollectionjson - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jjware/phpcollectionjson

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

jjware/phpcollectionjson
========================

PHP classes for building a Collection+JSON response

3.2.0(9y ago)2941MITPHPPHP &gt;=5.5.0

Since Oct 7Pushed 9y ago1 watchersCompare

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

READMEChangelog (7)DependenciesVersions (6)Used By (0)

PhpCollectionJson
=================

[](#phpcollectionjson)

PHP classes for building a Collection+JSON response.

Installation
------------

[](#installation)

```
composer require jjware/phpcollectionjson

```

Usage
-----

[](#usage)

### Creating a response

[](#creating-a-response)

```
use PhpCollectionJson\Document;
use PhpCollectionJson\Collection;
use PhpCollectionJson\Item;
use PhpCollectionJson\Data;

$document = new Document();
$collection = new Collection('http://www.somesite.com/users');
$document->setCollection($collection);

$item = new Item('http://www.somesite.com/users/123');
$item->getData()
    ->add(new Data('firstName', 'John'))
    ->add(new Data('lastName', 'Smith'))
    ->add(new Data('username', 'jsmith'));

$collection->getItems()->add($item);

echo json_encode($document);
```

### Building from a response

[](#building-from-a-response)

#### The JSON

[](#the-json)

```
{
  "collection": {
    "version": "1.0",
    "href": "http://www.somesite.com/users",
    "items": [
      {
        "href": "http://www.somesite.com/users/123",
        "data": [
          {
            "name": "firstName",
            "value": "John"
          },
          {
            "name": "lastName",
            "value": "Smith"
          },
          {
            "name": "username",
            "value": "jsmith"
          }
        ]
      }
    ]
  }
}
```

#### The PHP

[](#the-php)

```
use PhpCollectionJson\Document;

$json = file_get_contents('http://www.somesite.com/users'); // don't do this at home kids

$document = Document::fromJSON($json);

$firstName = $document->getCollection()->getItems()->elementAt(0)->getData()->elementAt(0)->getValue();

// $firstName === 'John'
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~1 days

Total

5

Last Release

3550d ago

Major Versions

2.0.0 → 3.0.02016-10-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef8f95f04f71a218a4fc2272480c25b4baaebc8961e30e03663bfbdc12225989?d=identicon)[JJWare](/maintainers/JJWare)

---

Top Contributors

[![senojj](https://avatars.githubusercontent.com/u/5853354?v=4)](https://github.com/senojj "senojj (12 commits)")

---

Tags

jsonlibrarycollectionscollectionjson

### Embed Badge

![Health badge](/badges/jjware-phpcollectionjson/health.svg)

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

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k328.4M753](/packages/justinrainbow-json-schema)[ergebnis/json-normalizer

Provides generic and vendor-specific normalizers for normalizing JSON documents.

8240.3M8](/packages/ergebnis-json-normalizer)[thunderer/serializard

Flexible serializer

2667.7k1](/packages/thunderer-serializard)[hamlet-framework/json-mapper

Json Data Binding

2711.9k](/packages/hamlet-framework-json-mapper)[jbuilder/common

This is a library for creating the structure of the JSON for PHP 5.4+

1330.9k1](/packages/jbuilder-common)[phppkg/config

Config manage, load, get. Supports INI,JSON,YAML,NEON,PHP format file

133.5k](/packages/phppkg-config)

PHPackages © 2026

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