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;
// Some example data:
$id = "2";
$type = 'test';
$attributes = ['test' => 'data'];
$json_api_response = new JsonApiFormatter();
$response = $json_api_response->dataResourceResponse($id, $type, $attributes);
// a json-api string, good for direct output