1. Go to this page and download the library: Download mk/hal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mk / hal example snippets
use MK\HAL\HALObject;
use MK\HAL\HALLink;
use MK\HAL\HALCurie;
$hal = new HALObject('/orders');
$hal->addData(array(
"offers" => 5,
"prices" => array(
"normal" => "10.99",
"season" => "5.99"
)
));
$hal->addCurie(new HALCurie('ea', 'http://example.com/docs/rels/{rel}'));
$hal->addLink('next', new HALLink('/orders?page=2'));
$hal->addLinkCollection('ea:admin', array(
new HALLink('/admin/2'),
new HALLink('/admin/5')
));
$product = new HALObject('/product/1');
$product->addLink('next', new HALLink('/product/2'));
$hal->embed('product', $product);
$hal->embedCollection('coupon', array(
new HALObject('/coupon/5'),
new HALObject('/coupon/6')
));
// use export() for json serialization
echo $hal->export(); // calls json_encode internally
// or simple encode the HALObject
echo json_encode($hal);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.