{"id":17191754,"url":"https://github.com/danbelden/php-siren","last_synced_at":"2025-04-06T06:27:49.640Z","repository":{"id":56961700,"uuid":"91066919","full_name":"danbelden/php-siren","owner":"danbelden","description":"A PHP Library for handling Siren JSON hypermedia","archived":false,"fork":false,"pushed_at":"2019-07-16T18:21:29.000Z","size":31,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-13T13:09:10.156Z","etag":null,"topics":["composer","hypermedia","json","php-library","siren"],"latest_commit_sha":null,"homepage":"http://sirenspec.org","language":"PHP","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/danbelden.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":"2017-05-12T08:03:28.000Z","updated_at":"2019-06-29T05:02:58.000Z","dependencies_parsed_at":"2022-08-21T10:20:38.668Z","dependency_job_id":null,"html_url":"https://github.com/danbelden/php-siren","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbelden%2Fphp-siren","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbelden%2Fphp-siren/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbelden%2Fphp-siren/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbelden%2Fphp-siren/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danbelden","download_url":"https://codeload.github.com/danbelden/php-siren/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247444783,"owners_count":20939901,"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":["composer","hypermedia","json","php-library","siren"],"created_at":"2024-10-15T01:27:18.486Z","updated_at":"2025-04-06T06:27:49.617Z","avatar_url":"https://github.com/danbelden.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# danbelden/php-siren\n\n[![Build Status](https://travis-ci.org/danbelden/php-siren.svg?branch=master)](https://travis-ci.org/danbelden/php-siren)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/danbelden/php-siren/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/danbelden/php-siren/?branch=master)\n[![Maintainability](https://api.codeclimate.com/v1/badges/6fb500c415e1e62a37b5/maintainability)](https://codeclimate.com/github/danbelden/php-siren/maintainability)\n[![Latest Stable Version](https://poser.pugx.org/danbelden/php-siren/version.svg)](https://packagist.org/packages/danbelden/php-siren)\n[![Total Downloads](https://poser.pugx.org/danbelden/php-siren/downloads.svg)](https://packagist.org/packages/danbelden/php-siren)\n\nA PHP Library for handling Siren JSON hypermedia documents\n\n# Overview\n\nThis is a library based around the Siren hypermedia data standard:\n- https://github.com/kevinswiber/siren\n- https://groups.google.com/forum/#!forum/siren-hypermedia\n\nIt provides objects and validation for handling this structured data format.\n\n# Requires\n\nPHP 5.3 and above.\n\n# Installation\n\n## Composer\n\nTo install this package with composer, run the following command:\n\n```composer require danbelden/php-siren \"^1.0\"```\n\n# Documentation\n\nUsing the example target JSON defined in the standards:\n- https://github.com/kevinswiber/siren\n\n```\n$document = new Document();\n$document-\u003eaddClass('order');\n\n$properties = [\n    'orderNumber' =\u003e 42,\n    'itemCount'   =\u003e 3,\n    'status'      =\u003e 'pending'\n];\n$document-\u003esetProperties($properties);\n\n$entityOne = new Entity();\n$entityOne-\u003esetClass([ 'items', 'collection' ])\n    -\u003esetRel([ 'http://x.io/rels/order-items' ])\n    -\u003esetHref('http://api.x.io/orders/42/items');\n\n$entityTwoLink = new Link();\n$entityTwoLink-\u003esetRel([ 'self' ])\n    -\u003esetHref('http://api.x.io/customers/pj123');\n\n$entityTwo = new Entity();\n$entityTwo-\u003esetClass([ 'info', 'customer' ])\n    -\u003esetRel([ 'http://x.io/rels/customer' ])\n    -\u003esetProperties([\n        'customerId' =\u003e 'pj123',\n        'name' =\u003e 'Peter Joseph'\n    ])\n    -\u003esetLinks([ $entityTwoLink ]);\n\n$entities = [ $entityOne, $entityTwo ];\n$document-\u003esetEntities($entities);\n\n$actionFieldOne = new Field();\n$actionFieldOne-\u003esetName('orderNumber')\n    -\u003esetType('hidden')\n    -\u003esetValue('42');\n\n$actionFieldTwo = new Field();\n$actionFieldTwo-\u003esetName('productCode')\n    -\u003esetType('text');\n\n$actionFieldThree = new Field();\n$actionFieldThree-\u003esetName('quantity')\n    -\u003esetType('number');\n\n$actionOne = new Action();\n$actionOne-\u003esetName('add-item')\n    -\u003esetTitle('Add Item')\n    -\u003esetMethod('POST')\n    -\u003esetHref('http://api.x.io/orders/42/items')\n    -\u003esetType('application/x-www-form-urlencoded')\n    -\u003esetFields([ $actionFieldOne, $actionFieldTwo, $actionFieldThree ]);\n\n$actions = [ $actionOne ];\n$document-\u003esetActions($actions);\n\n$linkOne = new Link();\n$linkOne-\u003esetRel([ 'self' ])\n    -\u003esetHref('http://api.x.io/orders/42');\n\n$linkTwo = new Link();\n$linkTwo-\u003esetRel([ 'previous' ])\n    -\u003esetHref('http://api.x.io/orders/41');\n\n$linkThree = new Link();\n$linkThree-\u003esetRel([ 'next' ])\n    -\u003esetHref('http://api.x.io/orders/43');\n\n$links = [ $linkOne, $linkTwo, $linkThree ];\n$document-\u003esetLinks($links);\n```\n\nEnjoy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanbelden%2Fphp-siren","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanbelden%2Fphp-siren","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanbelden%2Fphp-siren/lists"}