2017 © Pedro Peláez
 

library search-query-parser

a library to parse search query parameters from a rest request

image

php-platform/search-query-parser

a library to parse search query parameters from a rest request

  • Sunday, February 11, 2018
  • by Raaghu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 230 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

A Library for parsing search query parameters

Build Status, (*1)

When a Model from php-platform/persist is exposed as REST Resource (php-platform/restful), It is required that the REST End point to list all resources must support filter , sort and pagination, (*2)

Models extending php-platform/persist supports filter , sort and pagination through arguments to PhpPlatform\Persist\Model::find($filters,$sort,$pagination,$where) method, (*3)

So this library parses query parameters from rest endpoint to method arguments required by PhpPlatform\Persist\Model::find($filters,$sort,$pagination,$where), (*4)

How to use

php $searchParams = PhpPlatform\SearchQueryParser\Parser::parse(PhpPlatform\RESTFul\HTTPRequest $request,string $modelClassName, array $excludeFromFullTextSearch);, (*5)

where

  • $request is the HTTPRequest object received in the rest service
  • $modelClassName is the full name of the Model which is served as REST Resource
  • $excludeFromFullTextSearch is the array of fields which needs to be excluded from performing full text search

returns

An instance of PhpPlatform\SearchQueryParser\FindParams, (*6)

Parse rules

Query Param Method Parameter Format
q $where string for full text search , a complex $where expression is formed matching all the get fields from the Model , excluding the once mentioned in $excludeFromFullTextSearch. Auto Increment fields are excluded by default
f $filters base64 encoded json string representing the $filters object
s $sort base64 encoded json string representing the $sort object
p $pagination '<pageNumber>-<pageSize>'

Note 1 : This API throws PhpPlatform\Errors\Exceptions\Http\_4XX\BadRequest Exception if the query parameters are invalid Note 2 : All of the above query parameters are optional, (*7)

The Versions

11/02 2018

v0.1.x-dev

0.1.9999999.9999999-dev

a library to parse search query parameters from a rest request

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

11/02 2018

v0.1.1

0.1.1.0

a library to parse search query parameters from a rest request

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

07/02 2018

dev-master

9999999-dev

a library to parse search query parameters from a rest request

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

07/02 2018

v0.1.0

0.1.0.0

a library to parse search query parameters from a rest request

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires