jefersondaniel/siren-php

此包的最新版本(1.0.2)没有提供许可信息。

Siren超媒体类型PHP实现

1.0.2 2016-03-18 02:49 UTC

This package is auto-updated.

Last update: 2024-09-18 02:24:25 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Siren超媒体类型PHP实现

介绍

Siren是一种用于表示实体的超媒体规范。正如HTML用于在网站上视觉表示文档一样,Siren是用于通过Web API展示实体的规范。Siren提供了结构以传达关于实体的信息,动作以执行状态转换,以及链接以供客户端导航。

查看Siren规范

使用Composer安装

composer.phar require jefersondaniel/siren-php

编码资源

$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;