GitHub - json-api-php/json-api: Implementation of JSON API (http://jsonapi.org)...
source link: https://github.com/json-api-php/json-api
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
JSON API spec implemented in PHP 7. Immutable
The goal of this library is to ensure strict validity of JSON API documents being produced.
JSON:
{
"data": {
"type": "articles",
"id": "1",
"attributes": {
"title": "Rails is Omakase"
},
"relationships": {
"author": {
"data": {
"type": "people",
"id": "9"
},
"links": {
"self": "/articles/1/relationships/author",
"related": "/articles/1/author"
}
}
}
}
}
<?php
use JsonApiPhp\JsonApi\Attribute;
use JsonApiPhp\JsonApi\DataDocument;
use JsonApiPhp\JsonApi\Link\RelatedLink;
use JsonApiPhp\JsonApi\Link\SelfLink;
use JsonApiPhp\JsonApi\ResourceIdentifier;
use JsonApiPhp\JsonApi\ResourceObject;
use JsonApiPhp\JsonApi\ToOne;
echo json_encode(
new DataDocument(
new ResourceObject(
'articles',
'1',
new Attribute('title', 'Rails is Omakase'),
new ToOne(
'author',
new ResourceIdentifier('author', '9'),
new SelfLink('/articles/1/relationships/author'),
new RelatedLink('/articles/1/author')
)
)
),
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);
Installation
composer require json-api-php/json-api
Documentation
First, take a look at the examples. All of them are runnable.
The library API and use-cases are expressed in a comprehensive suite of tests.
Recommend
-
154
Guzzle, PHP HTTP client Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. Simple interface for building query strings, POST requests, streaming large uploads, str...
-
104
谈谈JSONAPI在PHP中的应用
-
84
fast_jsonapi - A lightning fast JSON:API serializer for Ruby Objects.
-
63
BlueChip BlueChip accepts payloads from GraphQL or JsonAPI servers, normalizes them into your store and provides an ORM like syntax for retrieving the data for use. Source
-
45
README.md PSR Http Client This repository holds all interfaces/classes/traits related to PSR-18.
-
39
README.md Jayway JsonPath A Java DSL for reading JSON documents.
-
19
README.md JSON implementation for Ruby
-
7
HTTP Enums For PHP 8.1 and above This package provides HTTP Methods, Status Codes and Reason Phrases as PHP 8.1+ enums All IANA registered HT...
-
3
swift-http-structured-headers A Swift implementation of the HTTP Structured Header Field Value specification. Provides parsing and serialization facilities for structured header field values, as well as implementations of Enc...
-
1
Jenkins Json API jenkins_url + /api/json?tree=jobs[name,color] builds
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK