PHPackages                             ytake/hhypermedia - 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. ytake/hhypermedia

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

ytake/hhypermedia
=================

for HATEOAS REST web services

0.6.1(5y ago)15.9k1MITHack

Since Mar 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ytake/hhypermedia)[ Packagist](https://packagist.org/packages/ytake/hhypermedia)[ RSS](/packages/ytake-hhypermedia/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (7)Versions (16)Used By (1)

Hhypermedia
===========

[](#hhypermedia)

Hypertext Application Language for HHVM/Hack

[![Travis (.org) branch(https://travis-ci.org/ytake/hhypermedia.svg?branch=master)](https://camo.githubusercontent.com/9712a3868fdf2bc2bfc2729062422e175ddd0c00098edb47a7d1351e2bce0713/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7974616b652f6868797065726d656469612f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/9712a3868fdf2bc2bfc2729062422e175ddd0c00098edb47a7d1351e2bce0713/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7974616b652f6868797065726d656469612f6d61737465722e7376673f7374796c653d666c61742d737175617265)[![Packagist](https://camo.githubusercontent.com/4ddde0cbdb1bb681835c283324423cea9ca3f74a9d28da077480931f6c1f6b04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7974616b652f6868797065726d656469612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ytake/hhypermedia)[![Packagist Version](https://camo.githubusercontent.com/cf33a3cbe4c1473802e4b4ebae4e025abbadf3a4136b48231fa8f95b91ff5e0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7974616b652f6868797065726d656469612e7376673f636f6c6f723d6f72616e6765267374796c653d666c61742d737175617265)](https://packagist.org/packages/ytake/hhypermedia)[![Packagist](https://camo.githubusercontent.com/f774d40c099f4b52dfbc96ee8832062832be78744729f18c6f58e43843214743/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7974616b652f6868797065726d656469612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ytake/hhypermedia)

Supported
---------

[](#supported)

[HAL - Hypertext Application Language](http://stateless.co/hal_specification.html)
[JSON Hypertext Application Language draft-kelly-json-hal-08](https://tools.ietf.org/html/draft-kelly-json-hal-08)
[vnd.error](https://github.com/blongden/vnd.error)

Requirements
------------

[](#requirements)

HHVM 4.0.0 and above.

1. [Installation](#1-installation)
2. [Usage](#2-usage)
3. [vnd.error](#3-vnd-error)

1.Installation
--------------

[](#1installation)

```
$ composer require ytake/hhypermedia
```

2.Usage
-------

[](#2usage)

Given a Hack Object, the hal+json transformer will represent the given data following the [`JSON Hypertext Application Language draft-kelly-json-hal-08`](https://tools.ietf.org/html/draft-kelly-json-hal-08) specification draft.

### Basic

[](#basic)

```
use type Ytake\Hhypermedia\Serializer\HalJsonSerializer;
use type Ytake\Hhypermedia\Link;
use type Ytake\Hhypermedia\LinkResource;
use type Ytake\Hhypermedia\Serializer;
use type Ytake\Hhypermedia\HalResource;
use type Ytake\Hhypermedia\ResourceObject;
use type Ytake\Hhypermedia\Visitor\JsonSerializationVisitor;

$link = new Link('self', vec[new LinkResource('/users')]);
$ro = new ResourceObject()
|> $$->withLink($link);
$resource = new HalResource($ro, dict['id' => 123456789]);

$secondRo = new ResourceObject()
|> $$->withEmbedded('tests', vec[$resource]);
$hal = new HalResource($secondRo);
$s = new Serializer(
  new HalJsonSerializer(),
  $hal,
  new JsonSerializationVisitor()
);
echo $s->serialize();
```

#### Basic - Result

[](#basic---result)

```
{
  "_embedded":{
    "tests":[
      {
        "id":123456789,
        "_links":{
          "self":{
            "href":"\/tests"
          }
        }
      }
    ]
  }
}
```

### Curies

[](#curies)

```
use type Ytake\Hhypermedia\Link;
use type Ytake\Hhypermedia\Curie;
use type Ytake\Hhypermedia\CurieResource;
use type Ytake\Hhypermedia\LinkResource;
use type Ytake\Hhypermedia\Serializer;
use type Ytake\Hhypermedia\HalResource;
use type Ytake\Hhypermedia\ResourceObject;
use type Ytake\Hhypermedia\Serializer\HalJsonSerializer;
use type Ytake\Hhypermedia\Visitor\JsonSerializationVisitor;

$ro = new ResourceObject()
|> $$->withLink(new Link('self', vec[new LinkResource('/tests')]))
|> $$->withLink(new Curie(vec[
  new CurieResource('http://haltalk.herokuapp.com/docs/{rel}', shape('name' => 'heroku'))
]));
$s = new Serializer(
  new HalJsonSerializer(),
  new HalResource($ro),
  new JsonSerializationVisitor()
);
echo $s->serialize();
```

#### Curies - Result

[](#curies---result)

```
{
  "_links":{
    "self":{
      "href":"\/tests"
    },
    "curies":[
      {
        "href":"http:\/\/haltalk.herokuapp.com\/docs\/{rel}",
        "templated":true,
        "name":"heroku"
      }
    ]
  }
}
```

3.vnd.error
-----------

[](#3vnderror)

Supported the [vnd.error](https://github.com/blongden/vnd.error).

```
use type Ytake\Hhypermedia\Serializer;
use type Ytake\Hhypermedia\LinkResource;
use type Ytake\Hhypermedia\Error\ErrorLink;
use type Ytake\Hhypermedia\Error\MessageResource;
use type Ytake\Hhypermedia\ResourceObject;
use type Ytake\Hhypermedia\Serializer\VndErrorSerializer;
use type Ytake\Hhypermedia\Visitor\JsonSerializationVisitor;

$linkVec = vec[new LinkResource('http://...')];
$new = new ResourceObject()
|> $$->withLink( new ErrorLink('help', $linkVec))
|> $$->withLink( new ErrorLink('about', $linkVec))
|> $$->withLink( new ErrorLink('describes', $linkVec));

$s = new Serializer(
  new VndErrorSerializer(),
  new MessageResource(
    'Validation failed',
    $new,
    shape('logref' => 42, 'path' => '/username')
  ),
  new JsonSerializationVisitor()
);
\var_dump($s->toDict());
```

### vnd.error - toDict

[](#vnderror---todict)

```
dict[
  'message' => 'Validation failed',
  'logref' => 42,
  'path' => '/username',
  '_links' => dict[
    'help' => dict[
      'href' => 'http://...'
    ],
    'about' => dict[
      'href' => 'http://...'
    ],
    'describes' => dict[
      'href' => 'http://...'
    ],
  ]
]
```

### vnd.error - Result

[](#vnderror---result)

```
{
  "message": "Validation failed",
  "path": "/username",
  "logref": 42,
  "_links": {
    "about": {
      "href": "http://..."
    },
    "describes": {
      "href": "http://..."
    },
    "help": {
      "href": "http://..."
    }
  }
}
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~60 days

Recently: every ~106 days

Total

15

Last Release

2144d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/47817f3dd2890864096bd77ee772ec46061432f128988ca23939b0ca486d7bc3?d=identicon)[ytake](/maintainers/ytake)

---

Top Contributors

[![ytake](https://avatars.githubusercontent.com/u/4454078?v=4)](https://github.com/ytake "ytake (39 commits)")

---

Tags

hackhacklanghalhhvmhypertext-application-languagerestserializehalHypertext Application Language

### Embed Badge

![Health badge](/badges/ytake-hhypermedia/health.svg)

```
[![Health](https://phpackages.com/badges/ytake-hhypermedia/health.svg)](https://phpackages.com/packages/ytake-hhypermedia)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[nocarrier/hal

application/hal builder / formatter for PHP 5.3+

2032.0M21](/packages/nocarrier-hal)[api-platform/openapi

Models to build and serialize an OpenAPI specification.

353.3M48](/packages/api-platform-openapi)[api-platform/symfony

Symfony API Platform integration

323.2M67](/packages/api-platform-symfony)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)[api-platform/state

API Platform state interfaces

223.4M57](/packages/api-platform-state)

PHPackages © 2026

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