PHPackages                             kkamkou/collection-json.php - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. kkamkou/collection-json.php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

kkamkou/collection-json.php
===========================

PHP implementation of the Collection+JSON

1.1.0(11y ago)1118.8k3MITPHPPHP &gt;=5.3

Since Dec 13Pushed 10y ago4 watchersCompare

[ Source](https://github.com/kkamkou/collection-json.php)[ Packagist](https://packagist.org/packages/kkamkou/collection-json.php)[ Docs](http://github.com/kkamkou/collection-json.php)[ RSS](/packages/kkamkou-collection-jsonphp/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Collection+JSON
===============

[](#collectionjson)

[![Build Status](https://camo.githubusercontent.com/08fc097f05701514408093fb28bdf3623d13b54a6808993b7192f415a90229ad/68747470733a2f2f7472617669732d63692e6f72672f6b6b616d6b6f752f636f6c6c656374696f6e2d6a736f6e2e7068702e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/08fc097f05701514408093fb28bdf3623d13b54a6808993b7192f415a90229ad/68747470733a2f2f7472617669732d63692e6f72672f6b6b616d6b6f752f636f6c6c656374696f6e2d6a736f6e2e7068702e7376673f6272616e63683d6d6173746572)[![Coverage Status](https://camo.githubusercontent.com/3e7a85c67d25bb582e46b00316f7dcc07c619dce04f0dbf9fc15d216d162b0d7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6b6b616d6b6f752f636f6c6c656374696f6e2d6a736f6e2e7068702f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/kkamkou/collection-json.php/?branch=master)

PHP implementation of the Collection+JSON [specification](http://amundsen.com/media-types/collection/format/)

Examples of media type in use [can be found here](http://amundsen.com/media-types/collection/examples/).

Example
-------

[](#example)

More examples are located in the `CollectionTest.php` test file

```
use \CollectionJson\Collection;
use \CollectionJson\Property;

$data = new Property\Data('firstName', 'Duck', 'Full name');
$link = new Property\Link('http://example.com', 'homepage', 'Homepage', 'link', 'Link to the homepage');

$item = new Collection\Item('http://example.com/item');
$item->addData($data)->addLink($link);

$collection = new Collection('http://example.com');
$collection->addItem($item);

echo $collection;
```

Signatures
----------

[](#signatures)

```
\CollectionJson\Collection($href);

\CollectionJson\Collection\Item($href, array $setWithData = array(), array $setWithLinks = array());
\CollectionJson\Collection\Template(array $setWithData = array());
\CollectionJson\Collection\Error($title = null, $code = null, $message = null);

\CollectionJson\Property\Data($name, $value = null, $prompt = null);
\CollectionJson\Property\Link($href, $rel, $name = null, $render = null, $prompt = null);
\CollectionJson\Property\Query($href, $rel, $name = null, $prompt = null, array $data = array());
```

Docker
------

[](#docker)

```
[sudo] docker build -t collection-json.php .
[sudo] docker run -v "$PWD:/opt/collection-json.php collection-json.php phpcs --standard=psr2 CollectionJson
[sudo] docker run -v "$PWD:/opt/collection-json.php collection-json.php phpunit -c tests/phpunit.xml tests
```

Tests
-----

[](#tests)

```
phpcs --standard=psr2 CollectionJson
phpunit -c tests/phpunit.xml tests
```

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2013-2015 Kanstantsin Kamkou

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

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

Every ~503 days

Total

2

Last Release

4031d ago

### Community

Maintainers

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

---

Top Contributors

[![kkamkou](https://avatars.githubusercontent.com/u/305739?v=4)](https://github.com/kkamkou "kkamkou (46 commits)")

---

Tags

jsonapirestcollection-json

### Embed Badge

![Health badge](/badges/kkamkou-collection-jsonphp/health.svg)

```
[![Health](https://phpackages.com/badges/kkamkou-collection-jsonphp/health.svg)](https://phpackages.com/packages/kkamkou-collection-jsonphp)
```

###  Alternatives

[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69114.3k](/packages/serpapi-google-search-results-php)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)[jsor/hal-client

A lightweight client for consuming and manipulating Hypertext Application Language (HAL) resources.

2425.9k1](/packages/jsor-hal-client)[elao/json-http-form-bundle

Adds support of JSON requests for Forms

356.0k](/packages/elao-json-http-form-bundle)

PHPackages © 2026

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