A PHP library for creating and formatting hypermedia documents in application/hal+json and application/hal+xml.
Nocarrier\Hal is a PHP library for creating and formatting hypermedia documents in the HAL (Hypertext Application Language) formats. It provides a simple API to build JSON and XML representations of resources with links and embedded data, solving the problem of implementing HAL-compliant APIs in PHP applications.
PHP developers building RESTful APIs that require hypermedia support, particularly those implementing the HAL specification for resource linking and discoverability.
Developers choose Nocarrier\Hal for its clean, object-oriented API that fully supports the HAL specification, including multi-format output and easy parsing of existing documents, without external dependencies.
application/hal builder / formatter for PHP 5.4+
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates both HAL+JSON and HAL+XML from the same codebase, demonstrated by the asJson() and asXml() methods, making it versatile for APIs requiring multiple content types.
Offers a fluent PHP interface for building HAL resources with links and embedded data, as shown in the clear examples for addLink() and addResource().
Can create HAL resources from existing JSON or XML strings via fromJson() and fromXml(), facilitating integration with external APIs or legacy systems.
Closely follows the HAL draft standard, ensuring compatibility with other HAL-compliant tools and promoting hypermedia principles in API design.
Requires PHP 8.2 or later, which may exclude projects on older PHP versions without feasible upgrade paths.
Limited to HAL format only, lacking features for general API development like error handling, validation, or support for other hypermedia types.
Parsing methods default to a depth of 0, potentially requiring manual adjustment for deeply nested embedded resources, as noted in the README.
README provides basic examples but lacks guidance on edge cases, performance considerations, or integration with larger frameworks like Laravel or Symfony.