{"id":18498436,"url":"https://github.com/zircote/hal","last_synced_at":"2025-04-09T21:18:24.832Z","repository":{"id":2584481,"uuid":"3565670","full_name":"zircote/Hal","owner":"zircote","description":"A PHP implementation of HAL http://stateless.co/hal_specification.html","archived":false,"fork":false,"pushed_at":"2015-04-25T06:04:54.000Z","size":262,"stargazers_count":94,"open_issues_count":3,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T21:18:21.431Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"stevenmiller888/matter-react","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zircote.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE-2.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-27T22:34:57.000Z","updated_at":"2025-02-03T11:42:33.000Z","dependencies_parsed_at":"2022-08-20T07:01:37.485Z","dependency_job_id":null,"html_url":"https://github.com/zircote/Hal","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zircote%2FHal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zircote%2FHal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zircote%2FHal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zircote%2FHal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zircote","download_url":"https://codeload.github.com/zircote/Hal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248111973,"owners_count":21049578,"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":[],"created_at":"2024-11-06T13:39:52.182Z","updated_at":"2025-04-09T21:18:24.809Z","avatar_url":"https://github.com/zircote.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hal\n[![Build Status](https://secure.travis-ci.org/zircote/Hal.png)](http://travis-ci.org/zircote/Hal)\n\n * [HAL IETF Draft](http://tools.ietf.org/html/draft-kelly-json-hal)\n * [HAL Specification](http://stateless.co/hal_specification.html)\n * [Hal Specification on Github](https://github.com/mikekelly/hal_specification)\n * [JSON Linking With HAL](http://blog.stateless.co/post/13296666138/json-linking-with-hal)\n * [Linking In Json](http://www.mnot.net/blog/2011/11/25/linking_in_json)\n * [Examples of HAL](https://gist.github.com/2289546)\n * [HAL on Google Groups](https://groups.google.com/d/forum/hal-discuss)\n\n```php\n\u003c?php\nuse Hal\\Resource,\n    Hal\\Link;\n/* Create a new Resource Parent */\n$parent = new Resource('/dogs');\n/* Add any relevent links */\n$parent-\u003esetLink(new Link('/dogs?q={text}', 'search'));\n$dogs[1] =  new Resource('/dogs/1');\n$dogs[1]-\u003esetData(\n    array(\n        'id' =\u003e '1', \n        'name' =\u003e 'tiber', \n        'color' =\u003e 'black'\n    )\n);\n$dogs[2] =  new Resource(\n    '/dogs/2',array(\n        'id' =\u003e '2', \n        'name' =\u003e 'sally', \n        'color' =\u003e 'white'\n    )\n);\n$dogs[3] =  new Resource(\n    '/dogs/3',array(\n        'id' =\u003e '3', \n        'name' =\u003e 'fido', \n        'color' =\u003e 'gray'\n    )\n);\n/* Add the embedded resources */\nforeach ($dogs as $dog) {\n    $parent-\u003esetEmbedded('dog', $dog);\n}\necho (string) $parent;\n```\n\n### Result: \n\n```javascript\n{\n  \"_links\":{\n\t\t\"self\":{\n\t\t\t\"href\":\"\\/dogs\"\n\t\t},\n\t\t\"search\":{\n\t\t\t\"href\":\"\\/dogs?q={text}\"\n\t\t}\n\t},\n\t\"_embedded\":{\n\t\t\"dog\":[\n\t\t\t{\n\t\t\t\t\"_links\":{\n\t\t\t\t\t\"self\":{\n\t\t\t\t\t\t\"href\":\"\\/dogs\\/1\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"id\":\"1\",\n\t\t\t\t\"name\":\"tiber\",\n\t\t\t\t\"color\":\"black\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"_links\":{\n\t\t\t\t\t\"self\":{\n\t\t\t\t\t\t\"href\":\"\\/dogs\\/2\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"id\":\"2\",\n\t\t\t\t\"name\":\"sally\",\n\t\t\t\t\"color\":\"white\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"_links\":{\n\t\t\t\t\t\"self\":{\n\t\t\t\t\t\t\"href\":\"\\/dogs\\/3\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"id\":\"3\",\n\t\t\t\t\"name\":\"fido\",\n\t\t\t\t\"color\":\"gray\"\n\t\t\t}\n\t\t]\n\t}\n}\n```\n## Generating XML output\n\n```php\n\u003c?php\necho $parent-\u003egetXML()-\u003easXML();\n```\n### Result:\n```xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003cresource href=\"/dogs\"\u003e\n    \u003clink href=\"/dogs?q={text}\" rel=\"search\" /\u003e\n    \u003cresource href=\"/dogs/1\" rel=\"dog\"\u003e\n        \u003cid\u003e1\u003c/id\u003e\n        \u003cname\u003etiber\u003c/name\u003e\n        \u003ccolor\u003eblack\u003c/color\u003e\n    \u003c/resource\u003e\n    \u003cresource href=\"/dogs/2\" rel=\"dog\"\u003e\n        \u003cid\u003e2\u003c/id\u003e\n        \u003cname\u003esally\u003c/name\u003e\n        \u003ccolor\u003ewhite\u003c/color\u003e\n    \u003c/resource\u003e\n    \u003cresource href=\"/dogs/3\" rel=\"dog\"\u003e\n        \u003cid\u003e3\u003c/id\u003e\n        \u003cname\u003efido\u003c/name\u003e\n        \u003ccolor\u003egray\u003c/color\u003e\n    \u003c/resource\u003e\n\u003c/resource\u003e\n```\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/zircote/hal/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzircote%2Fhal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzircote%2Fhal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzircote%2Fhal/lists"}