PHP code example of floor9design / json-api-formatter

1. Go to this page and download the library: Download floor9design/json-api-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/ */

    

floor9design / json-api-formatter example snippets


use Floor9design\JsonApiFormatter\Models\JsonApiFormatter;

// setup a data resource:
$data_resource = new DataResource(
    'NCC-1701-A',
    'starship',
    ['name' => 'Enterprise']
);

$response = $json_api_formatter->dataResourceResponse($data_resource);
// a json-api string, good for direct output