Download the PHP package bobbysciacchitano/manuel without Composer
On this page you can find all versions of the php package bobbysciacchitano/manuel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bobbysciacchitano/manuel
More information about bobbysciacchitano/manuel
Files in bobbysciacchitano/manuel
Package manuel
Short Description A simple object serializer for PHP which supports flexible document structures.
License MIT
Homepage https://github.com/bobbysciacchitano/manuel
Informations about the package manuel
Manuel
The easy to use PHP Serializer. Because translation shouldn't be a chore.
How to use
To serialize an object you first need to create a transformer. Transformers must implement the transform method and return an array. Transformers can accept any type of data or object that requires serialisation.
To serialize your data into a resource, you can wrap it in a Resource object. Wrapping the data into in a Resource tells Manuel whether you want to return a collection or a single resource. You can also declare your own resource types.
The above transformer with the Json API serializer will generate the following representation:
Associations
Manuel can handle an variety of association types. It is the responsibility of the serializer to translate the relationship into the correct format.
Simple Relationship
Simple relationships can be used to contrive additional data or return a simple value. When used with the JsonAPI serializer, this type of resource relationship can be used to declare a reference to an object that is not embedded or side-loaded.
Linked Resources
Much like simple relationships, this type of resource can be used to create a link reference to another resource that can be loaded from the API.
Embedded Resources
Much like simple relationships, embedded resources can be used to nest another resource within the resource tree. Embedded resources can be either a or and the serializer will attempt to serialize all relationships underneath.
Sideloaded Resources
This type of resource will be included along side the main resource and references to the resource identifiers can be loaded as part of the relationship serialization.
Serializers
Manuel out of the box includes a basic implementation of the JsonAPI serializer. The abstract serializer includes a flexible API which can form the basis for your own serializer.