Skip to content
/ hal Public
forked from blongden/hal

application/hal builder / formatter for PHP 5.3+

License

Notifications You must be signed in to change notification settings

raykolbe/hal

 
 

Repository files navigation

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
require_once 'vendor/autoload.php';

use Nocarrier\Hal;

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

$resource = new Hal(
    '/orders/123',
    array(
        'total' => 30.00,
        'currency' => 'USD',
    )
);

$resource->addLink('customer', '/customer/bob', array('title' => 'Bob Jones <[email protected]>'));
$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": "0.9.*"
    }
}

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

License

Nocarrier\Hal is licensed under the MIT license.

About

application/hal builder / formatter for PHP 5.3+

Resources

License

Stars

Watchers

Forks

Packages

No packages published