{"id":18124589,"url":"https://github.com/mhndev/hal","last_synced_at":"2025-07-21T03:33:13.523Z","repository":{"id":62527828,"uuid":"110428323","full_name":"mhndev/hal","owner":"mhndev","description":"Php Hal Object creation and manipulation from array data","archived":false,"fork":false,"pushed_at":"2017-11-20T08:00:31.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-11T08:06:04.477Z","etag":null,"topics":["hal","http","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mhndev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-12T11:53:03.000Z","updated_at":"2023-03-05T04:52:00.000Z","dependencies_parsed_at":"2022-11-02T14:30:22.573Z","dependency_job_id":null,"html_url":"https://github.com/mhndev/hal","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/mhndev/hal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhndev%2Fhal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhndev%2Fhal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhndev%2Fhal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhndev%2Fhal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mhndev","download_url":"https://codeload.github.com/mhndev/hal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhndev%2Fhal/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266235438,"owners_count":23897180,"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":["hal","http","php"],"created_at":"2024-11-01T08:06:43.305Z","updated_at":"2025-07-21T03:33:13.504Z","avatar_url":"https://github.com/mhndev.png","language":"PHP","readme":"[![Build Status](https://travis-ci.org/mhndev/hal.svg?branch=master)](https://travis-ci.org/mhndev/hal)\n[![Latest Stable Version](https://poser.pugx.org/mhndev/hal/v/stable)](https://packagist.org/packages/mhndev/hal)\n[![Total Downloads](https://poser.pugx.org/mhndev/hal/downloads)](https://packagist.org/packages/mhndev/hal)\n[![Latest Unstable Version](https://poser.pugx.org/mhndev/hal/v/unstable)](https://packagist.org/packages/mhndev/hal)\n[![License](https://poser.pugx.org/mhndev/hal/license)](https://packagist.org/packages/mhndev/hal)\n[![composer.lock](https://poser.pugx.org/mhndev/hal/composerlock)](https://packagist.org/packages/mhndev/hal)\n\n\n\n### Php Hal Object \n\ngenerating php hal object from array data\n\nthis package currently just supports  json and not xml\n\n\n#### Sample usage:\n\n```php\n\n$post = [\n    'title' =\u003e 'sample post title',\n    'text' =\u003e 'post body goes here ...',\n];\n\n$user = [\n    'username' =\u003e 'mhndev',\n    'mobile' =\u003e '09124917706',\n    'email' =\u003e 'majid8911303@gmail.com'\n];\n\n\n$comments = [\n    [\n        'text' =\u003e 'Hi',\n        'uid'  =\u003e 12\n    ],\n    [\n        'text' =\u003e 'OK',\n        'uid'  =\u003e 14\n    ],\n    [\n        'text' =\u003e 'NOK',\n        'uid'  =\u003e 10\n    ]\n];\n\n$tags = [\n    'tag1', 'tag2', 'tag3'\n];\n\n$profile = [\n    'avatar' =\u003e 'http://google.com/inja.jpeg',\n    'name' =\u003e 'majid',\n    'username' =\u003e 'mhndev',\n    'bio' =\u003e 'user biography goes here ...'\n];\n\n\n\n$self_link = new \\mhndev\\hal\\Link('self', 'http://google.com');\n$next_link = new \\mhndev\\hal\\Link('next', 'http://google.com');\n\n$postResource = new \\mhndev\\hal\\Resource($post);\n\n$profileResource = new \\mhndev\\hal\\Resource($profile);\n$profileResource-\u003eaddLink($self_link);\n\n\n$userResource = new \\mhndev\\hal\\Resource($user);\n\n$userResource-\u003eaddEmbeddedResource($profileResource, 'profile');\n\n$tagsResource = new \\mhndev\\hal\\Resource($tags);\n\n$request = \\Slim\\Http\\Request::createFromGlobals([]);\n\n\n$commentsResource = new \\mhndev\\hal\\Paginated($comments, 5 , 10, $request);\n\n\n\n$postResource-\u003eaddEmbeddedResource($userResource, 'user');\n$postResource-\u003eaddEmbeddedResource($tagsResource, 'tags');\n$postResource-\u003eaddEmbeddedResource($commentsResource, 'comments');\n\n$postResource-\u003eaddLink($next_link);\n$postResource-\u003eaddLink($self_link);\n\nheader('Content-Type: application/json');\n\n\n$presenter = new \\mhndev\\hal\\Presenter($postResource);\n\nvar_dump((new \\mhndev\\hal\\Presenter($postResource))-\u003easArray());die();\n\n\necho $presenter-\u003easJson();\n\n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhndev%2Fhal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmhndev%2Fhal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhndev%2Fhal/lists"}