Download the PHP package ngabor84/lumen-api-query-parser without Composer
On this page you can find all versions of the php package ngabor84/lumen-api-query-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ngabor84/lumen-api-query-parser
More information about ngabor84/lumen-api-query-parser
Files in ngabor84/lumen-api-query-parser
Package lumen-api-query-parser
Short Description A query parser for REST-APIs based on laravel's lumen framework
License MIT
Homepage https://github.com/ngabor84/lumen-api-query-parser
Informations about the package lumen-api-query-parser
Lumen API query parser
Description
This is a simple request query parameter parser for REST-APIs based on Laravel's Lumen framework.
Requirements
- PHP >=7.1
- Lumen framework >= 5.4
- Mockery >= 0.9 (dev)
- PHPUnit >= 6.1 (dev)
- PHP CodeSniffer >= 3.0.0 RC4 (dev)
Installation
- Add ngabor84/lumen-api-query-parser to your composer.json and make composer update, or composer require ngabor84/lumen-api-query-parser ~1.0
- Setup the service provider: in bootstrap/app.php add the following line:
Usage
Query syntax
Eager loading
Q: /users?connection[]=profile
R: will return the collection of the users with their profiles included
Filtering
Q: /users?filter[]=name:ct:admin
R: will return the collection of the users whose names contains the admin string
Available filter options
Operator | Description | Example |
---|---|---|
ct | String contains | name:ct:Peter |
nct | String NOT contains | name:nct:Peter |
sw | String starts with | username:sw:admin |
ew | String ends with | email:ew:gmail.com |
eq | Equals | level:eq:3 |
ne | Not equals | level:ne:4 |
gt | Greater than | level:gt:2 |
ge | Greater than or equal | level:ge:3 |
lt | Lesser than | level:lt:4 |
le | Lesser than or equal | level:le:3 |
in | In array | level:in:1|2|3 |
Sorting
Q: /users?sort[]=name:ASC
R: will return the collection of the users sort by their names ascending
Pagination
Q: /users?limit=10&page=3
R: will return a part of the collection of the users (from the 21st to 30th)