{"id":15789696,"url":"https://github.com/ytake/hhypermedia","last_synced_at":"2026-02-03T01:07:11.426Z","repository":{"id":57088256,"uuid":"120975534","full_name":"ytake/hhypermedia","owner":"ytake","description":"Hypertext Application Language for HHVM/Hack","archived":false,"fork":false,"pushed_at":"2020-07-01T12:33:03.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-05T22:03:03.586Z","etag":null,"topics":["hack","hacklang","hal","hhvm","hypertext-application-language"],"latest_commit_sha":null,"homepage":null,"language":"Hack","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ytake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-10T02:01:25.000Z","updated_at":"2020-07-01T12:28:59.000Z","dependencies_parsed_at":"2022-08-20T15:31:13.816Z","dependency_job_id":null,"html_url":"https://github.com/ytake/hhypermedia","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/ytake/hhypermedia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fhhypermedia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fhhypermedia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fhhypermedia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fhhypermedia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ytake","download_url":"https://codeload.github.com/ytake/hhypermedia/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fhhypermedia/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262003916,"owners_count":23243347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hack","hacklang","hal","hhvm","hypertext-application-language"],"created_at":"2024-10-04T22:02:59.271Z","updated_at":"2026-02-03T01:07:06.397Z","avatar_url":"https://github.com/ytake.png","language":"Hack","readme":"# Hhypermedia\n\nHypertext Application Language for HHVM/Hack\n\n![Travis (.org) branch(https://travis-ci.org/ytake/hhypermedia.svg?branch=master)](https://img.shields.io/travis/ytake/hhypermedia/master.svg?style=flat-square)\n[![Packagist](https://img.shields.io/packagist/dt/ytake/hhypermedia.svg?style=flat-square)](https://packagist.org/packages/ytake/hhypermedia)\n[![Packagist Version](https://img.shields.io/packagist/v/ytake/hhypermedia.svg?color=orange\u0026style=flat-square)](https://packagist.org/packages/ytake/hhypermedia)\n[![Packagist](https://img.shields.io/packagist/l/ytake/hhypermedia.svg?style=flat-square)](https://packagist.org/packages/ytake/hhypermedia)\n\n## Supported\n\n[HAL - Hypertext Application Language](http://stateless.co/hal_specification.html)  \n[JSON Hypertext Application Language draft-kelly-json-hal-08](https://tools.ietf.org/html/draft-kelly-json-hal-08)  \n[vnd.error](https://github.com/blongden/vnd.error)\n\n## Requirements\n\nHHVM 4.0.0 and above.\n\n1. [Installation](#1-installation)\n2. [Usage](#2-usage)\n3. [vnd.error](#3-vnd-error)\n\n## 1.Installation\n\n```bash\n$ composer require ytake/hhypermedia\n```\n\n## 2.Usage\n\nGiven a Hack Object,\nthe 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.\n\n### Basic\n\n```hack\nuse type Ytake\\Hhypermedia\\Serializer\\HalJsonSerializer;\nuse type Ytake\\Hhypermedia\\Link;\nuse type Ytake\\Hhypermedia\\LinkResource;\nuse type Ytake\\Hhypermedia\\Serializer;\nuse type Ytake\\Hhypermedia\\HalResource;\nuse type Ytake\\Hhypermedia\\ResourceObject;\nuse type Ytake\\Hhypermedia\\Visitor\\JsonSerializationVisitor;\n\n$link = new Link('self', vec[new LinkResource('/users')]);\n$ro = new ResourceObject()\n|\u003e $$-\u003ewithLink($link);\n$resource = new HalResource($ro, dict['id' =\u003e 123456789]);\n\n$secondRo = new ResourceObject()\n|\u003e $$-\u003ewithEmbedded('tests', vec[$resource]);\n$hal = new HalResource($secondRo);\n$s = new Serializer(\n  new HalJsonSerializer(),\n  $hal,\n  new JsonSerializationVisitor()\n);\necho $s-\u003eserialize();\n```\n\n#### Basic - Result\n\n```json\n{\n  \"_embedded\":{\n    \"tests\":[\n      {\n        \"id\":123456789,\n        \"_links\":{\n          \"self\":{\n            \"href\":\"\\/tests\"\n          }\n        }\n      }\n    ]\n  }\n}\n```\n\n### Curies\n\n```hack\nuse type Ytake\\Hhypermedia\\Link;\nuse type Ytake\\Hhypermedia\\Curie;\nuse type Ytake\\Hhypermedia\\CurieResource;\nuse type Ytake\\Hhypermedia\\LinkResource;\nuse type Ytake\\Hhypermedia\\Serializer;\nuse type Ytake\\Hhypermedia\\HalResource;\nuse type Ytake\\Hhypermedia\\ResourceObject;\nuse type Ytake\\Hhypermedia\\Serializer\\HalJsonSerializer;\nuse type Ytake\\Hhypermedia\\Visitor\\JsonSerializationVisitor;\n\n$ro = new ResourceObject()\n|\u003e $$-\u003ewithLink(new Link('self', vec[new LinkResource('/tests')]))\n|\u003e $$-\u003ewithLink(new Curie(vec[\n  new CurieResource('http://haltalk.herokuapp.com/docs/{rel}', shape('name' =\u003e 'heroku'))\n]));\n$s = new Serializer(\n  new HalJsonSerializer(),\n  new HalResource($ro),\n  new JsonSerializationVisitor()\n);\necho $s-\u003eserialize();\n```\n\n#### Curies - Result\n\n```json\n{\n  \"_links\":{\n    \"self\":{\n      \"href\":\"\\/tests\"\n    },\n    \"curies\":[\n      {\n        \"href\":\"http:\\/\\/haltalk.herokuapp.com\\/docs\\/{rel}\",\n        \"templated\":true,\n        \"name\":\"heroku\"\n      }\n    ]\n  }\n}\n```\n\n## 3.vnd.error\n\nSupported the [vnd.error](https://github.com/blongden/vnd.error).\n\n```hack\nuse type Ytake\\Hhypermedia\\Serializer;\nuse type Ytake\\Hhypermedia\\LinkResource;\nuse type Ytake\\Hhypermedia\\Error\\ErrorLink;\nuse type Ytake\\Hhypermedia\\Error\\MessageResource;\nuse type Ytake\\Hhypermedia\\ResourceObject;\nuse type Ytake\\Hhypermedia\\Serializer\\VndErrorSerializer;\nuse type Ytake\\Hhypermedia\\Visitor\\JsonSerializationVisitor;\n\n$linkVec = vec[new LinkResource('http://...')];\n$new = new ResourceObject()\n|\u003e $$-\u003ewithLink( new ErrorLink('help', $linkVec))\n|\u003e $$-\u003ewithLink( new ErrorLink('about', $linkVec))\n|\u003e $$-\u003ewithLink( new ErrorLink('describes', $linkVec));\n\n$s = new Serializer(\n  new VndErrorSerializer(),\n  new MessageResource(\n    'Validation failed',\n    $new,\n    shape('logref' =\u003e 42, 'path' =\u003e '/username')\n  ),\n  new JsonSerializationVisitor()\n);\n\\var_dump($s-\u003etoDict());\n```\n\n### vnd.error - toDict\n\n```hack\ndict[\n  'message' =\u003e 'Validation failed',\n  'logref' =\u003e 42,\n  'path' =\u003e '/username',\n  '_links' =\u003e dict[\n    'help' =\u003e dict[\n      'href' =\u003e 'http://...'\n    ],\n    'about' =\u003e dict[\n      'href' =\u003e 'http://...'\n    ],\n    'describes' =\u003e dict[\n      'href' =\u003e 'http://...'\n    ],\n  ]\n]\n```\n\n### vnd.error - Result\n\n```json\n{\n  \"message\": \"Validation failed\",\n  \"path\": \"/username\",\n  \"logref\": 42,\n  \"_links\": {\n    \"about\": {\n      \"href\": \"http://...\"\n    },\n    \"describes\": {\n      \"href\": \"http://...\"\n    },\n    \"help\": {\n      \"href\": \"http://...\"\n    }\n  }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Fhhypermedia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fytake%2Fhhypermedia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Fhhypermedia/lists"}