Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
application/hal builder / formatter for PHP 5.4+
PHP
tree: 8df21bd985

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/Nocarrier
tests/Hal
.gitignore
.travis.yml
LICENSE
README.md
build.xml
composer.json
phpdoc.dist.xml
phpunit.xml.dist

README.md

Nocarrier\Hal

Build Status

This is a library for creating documents in the application/hal+json and application/hal+xml hypermedia formats

It requires PHP 5.3 or later.

<?php
$hal = new Nocarrier\Hal('/orders');
$hal->addLink('next', '/orders?page=2');
$hal->addLink('search', '/orders?id={order_id}');

$resource = new Nocarrier\Hal(
    '/orders/123',
    array(
        'total' => 30.00,
        'currency' => 'USD',
    )
);
$resource->addLink('customer', '/customer/bob', 'Bob Jones <bob@jones.com>');
$hal->addResource('order', $resource);
echo $hal->asJson();
echo $hal->asXml();

Installation

The preferred method of installation is via packagist as this provides the PSR-0 autoloader functionality. The following composer.json will download and install the latest version of the Hal library into your project.

{
    "require": {
        "nocarrier/hal": "*"
    }
}

Alternatively, clone the project and install into your project manually.

License

Nocarrier\Hal is licensed under the MIT license.

Something went wrong with that request. Please try again.