2017 © Pedro Peláez
 

library json-api

A PHP7 implement of JSON API specification

image

lemonphp/json-api

A PHP7 implement of JSON API specification

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

lemonphp/json-api

Build Status Coverage Status Code Climate Issue Count, (*1)

A PHP7 implement of JSON API specification, (*2)

Requirements

  • php >= 7.0

Installation

$ composer require lemonphp/json-api

Usage

Example code:, (*3)

<?php

use Lemon\JsonApi\Document;
use Lemon\JsonApi\Document\Resource\Relationship\Linkage;
use Lemon\JsonApi\Document\Resource\Relationship\Relationship;
use Lemon\JsonApi\Document\Resource\ResourceIdentifier;
use Lemon\JsonApi\Document\Resource\ResourceObject;

include_once 'vendor/autoload.php';

$author = Relationship::fromLinkage(
    Linkage::fromSingleIdentifier(
        new ResourceIdentifier('people', '9')
    )
);
$author->setLink('self', '/articles/1/relationships/author');
$author->setLink('related', '/articles/1/author');

$article = new ResourceObject('articles', '1');
$article->setAttribute('title', 'Hello word');
$article->setRelationship('author', $author);

$doc = Document::fromResource($article);
echo json_encode($doc, JSON_PRETTY_PRINT);

Output:, (*4)

{
    "data": {
        "type": "articles",
        "id": "1",
        "attributes": {
            "title": "Hello word"
        },
        "relationships": {
            "author": {
                "data": {
                    "type": "people",
                    "id": "9"
                },
                "links": {
                    "self": "\/articles\/1\/relationships\/author",
                    "related": "\/articles\/1\/author"
                }
            }
        }
    }
}

Changelog

See all change logs in CHANGELOG.md, (*5)

Contributing

All code contributions must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code., (*6)

Fork the project, create a feature branch, and send a pull request., (*7)

To ensure a consistent code base, you should make sure the code follows the PSR-2., (*8)

If you would like to help take a look at the list of issues., (*9)

License

This project is released under the MIT License.
Copyright © 2017 LemonPHP Team., (*10)

The Versions

03/07 2017

dev-master

9999999-dev https://github.com/lemonphp/json-api

A PHP7 implement of JSON API specification

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

api json-api