定制 json-api-php/json-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

json-api-php/json-api

最新稳定版本:3.0.0

Composer 安装命令:

composer require json-api-php/json-api

包简介

JSON API specs (jsonapi.org) as a set of PHP classes

README 文档

README

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:

<?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.

统计信息

  • 总下载量: 356.92k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 187
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 185
  • Watchers: 8
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-28