https://github.com/freeelephants/json-api-dto
JsonApi Document Structure Types
https://github.com/freeelephants/json-api-dto
data-transfer-object jsonapi jsonapi-resources php
Last synced: 11 months ago
JSON representation
JsonApi Document Structure Types
- Host: GitHub
- URL: https://github.com/freeelephants/json-api-dto
- Owner: FreeElephants
- License: bsd-2-clause
- Created: 2025-03-13T11:01:20.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-26T13:10:05.000Z (12 months ago)
- Last Synced: 2025-07-22T15:46:28.643Z (11 months ago)
- Topics: data-transfer-object, jsonapi, jsonapi-resources, php
- Language: PHP
- Homepage:
- Size: 45.9 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Json Api Toolkit
[](https://github.com/FreeElephants/json-api-dto/actions)
[](https://codecov.io/gh/FreeElephants/json-api-dto)
[](https://packagist.org/packages/free-elephants/json-api-dto)
[](https://github.com/FreeElephants/json-api-dto/releases)
## Features:
Build Data Transfer Objects from PSR7 Messages.
Full typed objects from request or response body.
See example in [test](/tests/FreeElephants/JsonApiToolkit/DTO/DocumentTest.php).
Union types support for relationships in PHP 8.
## Usage
Extend super types in your own json api documents and it's parts:
- \FreeElephants\JsonApi\DTO\AbstractAttributes
- \FreeElephants\JsonApi\DTO\AbstractDocument
- \FreeElephants\JsonApi\DTO\AbstractRelationships
- \FreeElephants\JsonApi\DTO\AbstractResourceObject
And use as properties types:
- \FreeElephants\JsonApi\DTO\RelationshipToOne
- \FreeElephants\JsonApi\DTO\ResourceIdentifierObject
See tests/ for more examples.
### Install
`composer require free-elephants/json-api-dto`
## Development
All dev env is dockerized. Your can use make receipts and `bin/` scripts without locally installed php, composer.
For run tests with different php version change `PHP_VERSION` value in .env and rebuild image with `make build`.