1. Go to this page and download the library: Download giadc/json-api-request 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/ */
giadc / json-api-request example snippets
use Giadc\JsonApiRequest\Requests\RequestParams;
// By default it creates params from Globals
$request = new RequestParams();
// Get Includes
$request->getIncludes()->toArray();
// outputs: ['author', 'comments.author']
// Get Page Details
$request->getPageDetails()->toArray();
// outputs: ['page' => ['number => 3, 'size' => 20]]
// Get Sorting
$request->getSortDetails()->toArray();
// outputs: [['field' => 'title', 'direction' => 'ASC'], ['field' => 'created', 'direction' => 'DESC']]
// Get Filters
$request->getFiltersDetails()->toArray();
// outputs: ['author' => ['frank']]
// Get Full Pagination
$request->getFullPagination();
// outputs: [{Pagination}, {Includes}, {Sorting}, {Filters}]
// Get Fields
$request->getFields()->toArray();
// outputs: ['author' => ['name', 'age']]
$$/outputs: '
$pagination = new Pagination(2, 20);
$pagination->getQueryString();
//outputs: 'page[number]=2&page[size]=20'
// PAGINATION_MAX=25
$pagination = new Pagination(2, 1000);
$pagination->getQueryString();
//outputs: 'page[number]=2&page[size]=25'
$sorting = new Sorting('-created,title');
$sorting->setSorting();
$sorting->getQueryString('created,-title');
//outputs: 'sort=created,title'