{"id":13621827,"url":"https://github.com/json-api-php/json-api","last_synced_at":"2026-01-11T16:50:40.949Z","repository":{"id":45485351,"uuid":"86419223","full_name":"json-api-php/json-api","owner":"json-api-php","description":"Implementation of JSON API in PHP","archived":false,"fork":false,"pushed_at":"2022-07-27T01:11:02.000Z","size":208,"stargazers_count":183,"open_issues_count":3,"forks_count":18,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-12T05:15:22.299Z","etag":null,"topics":["hacktoberfest","json","json-api","jsonapi","library","php","php7","psr"],"latest_commit_sha":null,"homepage":"https://json-api-php.github.io/","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/json-api-php.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://www.paypal.me/f3ath"}},"created_at":"2017-03-28T05:38:20.000Z","updated_at":"2024-07-03T13:40:31.000Z","dependencies_parsed_at":"2022-07-18T23:47:35.334Z","dependency_job_id":null,"html_url":"https://github.com/json-api-php/json-api","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-api-php%2Fjson-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-api-php%2Fjson-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-api-php%2Fjson-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-api-php%2Fjson-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/json-api-php","download_url":"https://codeload.github.com/json-api-php/json-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223661139,"owners_count":17181608,"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":["hacktoberfest","json","json-api","jsonapi","library","php","php7","psr"],"created_at":"2024-08-01T21:01:10.969Z","updated_at":"2026-01-11T16:50:40.940Z","avatar_url":"https://github.com/json-api-php.png","language":"PHP","readme":"# [JSON API](http://jsonapi.org) spec implemented in PHP 7. Immutable\n\nThe goal of this library is to ensure strict validity of JSON API documents being produced.\n\nJSON:\n```json\n{\n    \"data\": {\n        \"type\": \"articles\",\n        \"id\": \"1\",\n        \"attributes\": {\n            \"title\": \"Rails is Omakase\"\n        },\n        \"relationships\": {\n            \"author\": {\n                \"data\": {\n                    \"type\": \"people\",\n                    \"id\": \"9\"\n                },\n                \"links\": {\n                    \"self\": \"/articles/1/relationships/author\",\n                    \"related\": \"/articles/1/author\"\n                }\n            }\n        }\n    }\n}\n```\nPHP:\n```php\n\u003c?php\nuse JsonApiPhp\\JsonApi\\Attribute;\nuse JsonApiPhp\\JsonApi\\DataDocument;\nuse JsonApiPhp\\JsonApi\\Link\\RelatedLink;\nuse JsonApiPhp\\JsonApi\\Link\\SelfLink;\nuse JsonApiPhp\\JsonApi\\ResourceIdentifier;\nuse JsonApiPhp\\JsonApi\\ResourceObject;\nuse JsonApiPhp\\JsonApi\\ToOne;\n\necho json_encode(\n    new DataDocument(\n        new ResourceObject(\n            'articles',\n            '1',\n            new Attribute('title', 'Rails is Omakase'),\n            new ToOne(\n                'author',\n                new ResourceIdentifier('author', '9'),\n                new SelfLink('/articles/1/relationships/author'),\n                new RelatedLink('/articles/1/author')\n            )\n        )\n    ),\n    JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES\n);\n```\n## Installation\n`composer require json-api-php/json-api`\n\n## Documentation\n\nFirst, take a look at the examples. All of them are runnable.\n- [Simple Document](./examples/simple_doc.php) (the same as above)\n- [Extensive Compound Document](./examples/compound_doc.php)\n\nThe library API and use-cases are expressed in a comprehensive suite of tests.\n- Data Documents (containing primary data)\n    -  [with a single Resource Object](./test/DataDocument/SingleResourceObjectTest.php)\n    -  [with a single Resource Identifier](./test/DataDocument/SingleResourceIdentifierTest.php)\n    -  [with null data](./test/DataDocument/NullDataTest.php)\n    -  [with multiple Resource Objects](./test/DataDocument/ManyResourceObjectsTest.php)\n    -  [with multiple Resource Identifiers](./test/DataDocument/ManyResourceIdentifiersTest.php)\n    -  [with a new Resource (no id)](./test/NewResourceObjectTest.php)\n- [Compound Documents](./test/CompoundDocumentTest.php)\n- [Error Documents](./test/ErrorDocumentTest.php)\n- [Meta Documents (containing neither data nor errors)](./test/MetaDocumentTest.php)\n- [Pagination](./test/PaginationTest.php)\n- [Link Objects](./test/LinkObjectTest.php)\n- [JSON API Object](./test/JsonApiTest.php)\n- [Meta Objects](./test/MetaTest.php)\n","funding_links":["https://www.paypal.me/f3ath"],"categories":["PHP","Libraries"],"sub_categories":["PHP Libraries","Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson-api-php%2Fjson-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjson-api-php%2Fjson-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson-api-php%2Fjson-api/lists"}