floor9design/json-api-formatter
最新稳定版本:2.0.4
Composer 安装命令:
composer require floor9design/json-api-formatter
包简介
A set of classes that allow for creating JSON API compliant objects
README 文档
README
A set of classes that allow for creating JSON API compliant objects
Introduction
The JSON API has a precise response format. This set of classes allows these to be easily created and interrogated, meaning easy and reliable output/input processing.
Output is as simple as:
use Floor9design\JsonApiFormatter\Models\JsonApiFormatter; // setup a data resource: $data_resource = new DataResource( 'NCC-1701-A', 'starship', ['name' => 'Enterprise'] ); $response = $json_api_formatter->dataResourceResponse($data_resource); // a json-api string, good for direct output
Other responses and elements, such as errors, meta data, links and source elements are all supported.
For more examples, see usage.
Features
The classes offer:
- easy methods to wrap and unwrap content
- default values and settings out of the box, improving the quality of response
- fluent programming approach, allowing objects to be built on the fly
Install
Via Composer/packagist
composer require floor9design/json-api-formatter
Via git
git clone https://github.com/floor9design-ltd/json-api-formatter.git
Or:
git clone git@github.com:floor9design-ltd/json-api-formatter.git
Usage
This is discussed in the usage document.
Class reference
The class documentation is located in the class reference:
Setup
There are no specific config setup steps required. The class should autoload in PSR-4 compliant systems. If you are using the class on its own, simply include it however is most appropriate.
Testing
Tests can be run as follows:
./vendor/phpunit/phpunit/phpunit
Static analysis/code review can be performed by using phpstan:
./vendor/bin/phpstan
The following tests and also creates code coverage (usually maintained at 100%)
./vendor/phpunit/phpunit/phpunit --coverage-html docs/tests/
Note, the following are very useful for validating/testing outputs:
Credits
Changelog
A changelog is generated here:
License
This software is available under the MIT licence.
统计信息
- 总下载量: 27.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-15