Hypermedia Collection+Json Library for PHP

dev-master / 0.1.x-dev 2014-08-27 00:06 UTC

This package is not auto-updated.

Last update: 2023-06-06 02:11:20 UTC


! WIP Status

Link to the Collection+Json Specification :


Add the library to your composer.json file

    "require": {
        // your other deps,
        "kwattro/hypermedia-collection-json": "0.1@dev"


Usage of the library is simple :

Create a new Collection :

require_once 'vendor/autoload.php';

use Kwattro\Hypermedia\CollectionJson\Collection;

$collection = new Collection();

Add items to the collection

use Kwattro\Hypermedia\CollectionJson\Collection;
use Kwattro\Hypermedia\CollectionJson\Item;

$collection = new Collection();
$item = new Item();
$item->addData(array('name' => 'John', 'city' => 'Paradise City');


In order to serialize/deserialize objects, you just need to call the Serializer create static method :

use Kwattro\Hypermedia\CollectionJson\Serializer;

// $myCollection = ... creating collection and items objects

$json = Serializer::create()->serialize($myCollection); // Returns a Json representation

// Deserializing :
$myObject = Serializer::create()->deserialize($json); // Returns a Collection object


The lib is using phpspec

Running the test suite

bin/phpspec run


  • Implementing JMS/Serializer (partially done)
  • Full compliant with Hypermedia Spec