jefersondaniel/siren-php

There is no license information available for the latest version (1.0.2) of this package.

Siren hypermedia type implementation for PHP

1.0.2 2016-03-18 02:49 UTC

This package is auto-updated.

Last update: 2024-04-18 01:32:07 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Siren hypermedia type implementation for PHP

Introduction

Siren is a hypermedia specification for representing entities. As HTML is used for visually representing documents on a Web site, Siren is a specification for presenting entities via a Web API. Siren offers structures to communicate information about entities, actions for executing state transitions, and links for client navigation.

See siren specification

Installing with composer

composer.phar require jefersondaniel/siren-php

Encoding a resource

$collection = new SirenPHP\Entity(
    '/collection/1',
    ['count' => 3],
    ['collection']
);
$entity = new SirenPHP\Entity(
    '/book/1',
    ['name' => 'The Book 1'],
    ['book']
);
$collection->appendEntity(['item'], $entity);
$link = new SirenPHP\Link(['next'], '/collection/2');
$collection->appendLink($link);
  
echo (string) $collection;