1. Go to this page and download the library: Download yehiahamid/easyparse 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/ */
yehiahamid / easyparse example snippets
//values must be inside single or double quotes if it contains white spaces or special chars 'what ever' | "what ever"
$queryStringFilters = "@filters=name eq 'what ever',surname ne 'what ever'";
// otherwise you can use use the value without quotes
// ex :
$queryStringFilters = "@filters=id eq 12";
$queryStringFilters = "@filters=id eq anyWordsWithoutspacesOrSpecialChars";
//fields
$queryStringFields = "@fields=name,surname,code";
//name is assc , surname desc
$queryStringOrderBy = "@orderby=name,-surname";
//embed can contains fields,filters,sort and paging
$queryStringEmbed = "@embed=resourceOne(@fields=name,code)(@filters=nameembed eq 'what ever'),mobiles(@orderby=sortFieldOne)";
$queryString = $queryStringFilters . "&" . $queryStringFields . "&" . $queryStringOrderBy . "&" . $queryStringEmbed;
//in real app you would use $_SERVER['QUERY_STRING'];
//this is optional param if not set it will use server query string
$parser = new yehiaHamid\easyParse\QueryStringParser($queryString);
$parser->fields(); //return array of fields | null if empty
$parser->orderBy(); //return array of order by object | null if empty
//Or you can set default value
// use - before field for desc order
$parser->orderBy("fieldOne,-field");
$filtersResult = $parser->filters();
//the filter object has three fields
// the used query string in ex : "@filters=name eq 'what ever',surname ne 'what ever'"
$filtersResult[0]->field // name
$filtersResult[0]->operator // eq
$filtersResult[0]->getOperator() // "="
$filtersResult[0]->value // 'what ever'
$filtersResult[1]->field // surname
$filtersResult[1]->operator // ne
$filtersResult[1]->getOperator() // "!="
$filtersResult[1]->value // 'what ever'
//Or you can set default value for each of the following
$parser->offset();
$parser->limit();
$parser->perPage();
$parser->page();
// this new function return the value of
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.