Download the PHP package mk/hal without Composer
On this page you can find all versions of the php package mk/hal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package hal
Short Description Implementation of HAL standart for using in REST API responses or similiar
License MIT
Informations about the package hal
MKHal
This repository is still in a early development stage. If you find any issues or miss any feature please feel free to raise an issue.
MKHal is an implementation of the HAL specification written in PHP. It can be used to build a HAL specific data structure and convert it to JSON or XML. It can be easily implemented in your current API backend workflow.
Requirements
- PHP 7.0 or higher
Installation
You can clone or download the package and use it in your project or just install it via composer:
Usage
Object types
MKHal offers different class types to represent the structure of a typical HAL implementation:
- HALObject: The
HALObjectclass represents the main resource in the HAL specification. It can hold normal data,HALLinkobjects andHALCurieobjects. It can also embed additionalHALObjectsin referred by labels. - HALLink: The
HALLinkclass represents a typical link resources in the _links section of the HAL document. It can hold different information like the href attribute. It get automatically serialized along with anHALObjectinstance. AHALObjectcan hold additional links after different labels. - HALCurie: The
HALCurieclass is the representation of the curies attribute in HAL. AnHALObjectinstance can have multiple curies inside of it.
Basic usage
The call of the export() method creates a JSON representation of the HAL specification:
Roadmap
- [x] Implement basic HAL specification
- [x] Enable curies
- [x] Well structured class hierarchy
- [x] JSON export / output
- [x] Auto create HAL data from given objects
- [ ] XML export / output
- [ ] Read HAL objects to use library as client too
- [ ] Slim Framework integration