This package is abandoned and no longer maintained. No replacement package was suggested.

A library for creating and parsing Siren APIs in PHP

v0.1.0 2016-12-05 22:04 UTC

This package is not auto-updated.

Last update: 2023-11-11 15:45:20 UTC


A serialiser and parser for Siren APIs.


Siren is a schema for HATEOAS APIs which uses JSON.

Current State

This project's releases strongly adhere to SemVer. At this point in time, this project is in zero point state. While it's functionality is sound and working, large backwards compatibility breaks can be expected in new releases.


composer require tomphp/siren:dev-master


Creating an entity is done using the builder; this is created by calling TomPHP\Siren\Entity::builder().

use TomPHP\Siren\{Entity, Action};

$editAction = Action::builder()
    ->setTitle('Edit User')
    ->addField('email', ['email-class'], 'email', '', 'Email Address')

$user = Entity::builder()
    ->addLink('self', '')
    ->addProperty('full_name', 'Tom Oram')
    ->addProperty('email', '')



An entity can be created from a JSON decoded array by using fromArray() constructor.

// Assuming the JSON from the serialising example.

$user = Entity::fromArray(json_decode($json, true));

echo 'Name: ' . $user->getProperty('full_name') . PHP_EOL;
echo 'Email: ' . $user->getProperty('email') . PHP_EOL;

$editAction = $user->getAction('edit');
echo 'Edit Action ' . $editAction->getMehod() . ' ' . $editAction->getHref() . PHP_EOL;


I want to get this project stable as soon as possible, so any help I can get is greatly appreciated. If you think you can help, please submit a Pull Request.