PHP code example of germania-kg / response-decoder
1. Go to this page and download the library: Download germania-kg/response-decoder 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/ */
germania-kg / response-decoder example snippets
use Germania\ResponseDecoder\ResponseDecoderInterface;
use Germania\ResponseDecoder\JsonApiResponseDecoder;
$response = ...
$decoder = new JsonApiResponseDecoder;
// Both are arrays
$resourceCollection = $decoder->getResourceCollection($response);
$singleResource = $decoder->getResource($response);
use Germania\ResponseDecoder\JsonApiResponseDecoder;
$response = ...
$items = (new JsonApiResponseDecoder)->getResourceCollection($response);
print_r($items);
// Array {
// Array {
// "title" => "JSON:API paints my bikeshed!"
// },
// Array {
// "title" => "Rails is Omakase"
// }
// }
use Germania\ResponseDecoder\JsonApiResponseDecoder;
$response = ...
$item = (new JsonApiResponseDecoder)->getResource($response);
print_r($item);
// Array {
// "title" => "JSON:API paints my bikeshed!"
// }
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.