Download the PHP package bayfrontmedia/array-schema without Composer
On this page you can find all versions of the php package bayfrontmedia/array-schema. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bayfrontmedia/array-schema
More information about bayfrontmedia/array-schema
Files in bayfrontmedia/array-schema
Package array-schema
Short Description A simple library used to force a predefined "schema" for a given array.
License MIT
Homepage https://github.com/bayfrontmedia/array-schema
Informations about the package array-schema
Array Schema
A simple library used to force a predefined "schema" for a given array.
- License
- Author
- Requirements
- Installation
- Usage
- Included schemas
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0
Installation
Usage
The intended usage is for a custom schema to implement Bayfront\ArraySchema\SchemaInterface
.
This class ensures that the array conforms to its desired schema, or throws a Bayfront\ArraySchema\InvalidSchemaException
.
The SchemaInterface
contains only one static method:
- create
create
Description:
Returns an array conforming to the desired schema.
Parameters:
$array
(array): Input array$config = []
(array): Optional configuration array which can be used to pass options necessary to build the desired schema.
Returns:
- (array)
Throws:
Bayfront\ArraySchema\InvalidSchemaException
Included schemas
This library includes some example schemas which aid in building JSON responses in accord with the latest JSON API specification.
These are by no means meant to be a "catch-all" solution, nor do they enforce all the JSON:API specifications. They are merely included as an example usage reference.
- ResourceDocument
- ResourceCollectionDocument
- ErrorDocument
ResourceDocument
$array
is a single resource to return.- If
$config['base_url']
exists, its value will be removed from any links that are returned.
Example:
The above example would return:
ResourceCollectionDocument
$array
is an array of resource to return.- If
$config['base_url']
exists, its value will be removed from any links that are returned. - If
$config['meta_results']
exists, it will be used to return aResourceCollectionMetaResults
andResourceCollectionPagination
schema.
Example:
The above example would return:
ErrorDocument
$array
is an array of errors to return.- If
$config['base_url']
exists, its value will be removed from any links that are returned.
Example:
The above example would return:
All versions of array-schema with dependencies
bayfrontmedia/php-array-helpers Version ^2.0
bayfrontmedia/php-http-request Version ^3.0
bayfrontmedia/php-http-response Version ^2.0