PHP code example of budgetdumpster / hal-formatter

1. Go to this page and download the library: Download budgetdumpster/hal-formatter 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/ */

    

budgetdumpster / hal-formatter example snippets


$embedded = [
    'person' => [
        'property' => 'person',
        'key' => 'person',
        'uri' => 'person'
    ]
];



use BudgetDumpster\Formatters\HalFormatter;
use NameSpace\Models\Address;

$address = new Address();
$collection = $address->where('city', 'like', '%Westlake%');
$embedded = [
    'person' => [
        'property' => 'person',
        'key' => 'person',
        'uri' => 'person'
    ]
];
$formatter = new HalFormatter();
$responseBody = $formatter->formatResource($collection, $uri = 'address', $embedded);