New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

ngabor84/lumen-api-query-parser

A query parser for REST-APIs based on laravel's lumen framework
1,494 3

Larablocks Analysis

ngabor84/lumen-api-query-parser works with any PHP project: the latest release (1.4.0, Dec 4, 2019) doesn't depend on Laravel.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • No release in the last 12 months (last: Dec 4, 2019)
  • 9 downloads a month (needs 10,000)
  • 3 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Dec 4, 2019.
  • No releases in the last 12 months.
  • First released: May 3, 2017.
  • Monthly downloads: 9.
  • 4 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 3, 2026.

Install
composer require ngabor84/lumen-api-query-parser
Latest Version:1.4.0
PHP:^7.3
License:MIT
Last Updated:Apr 22, 2022
Links: GitHub  ·  Packagist
Maintainer: ngabor84

Lumen API query parser

Codeship Status for ngabor84/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:
    $app->register(LumenApiQueryParser\Provider\RequestQueryParserProvider::class);
    

Usage

    // app/API/V1/Models/UserController.php
    namespace App\Api\V1\Http\Controllers;
    
    use App\Api\V1\Models\User;
    use App\Api\V1\Transformers\UserTransformer;
    use LumenApiQueryParser\ResourceQueryParserTrait;
    use LumenApiQueryParser\BuilderParamsApplierTrait;
    
    class UserController extends Controller
    {
        use ResourceQueryParserTrait;
        use BuilderParamsApplierTrait;
                
        public function index(Request $request)
        {
            $params = $this->parseQueryParams($request);
            $query = User::query();
            $userPaginator = $this->applyParams($query, $params);
            
            $this->response->paginator($userPaginator, new UserTransformer, ['key' => 'users']);
        }
    }

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)

Related Packages

bwt-team/laravel-api

Package helping with API development

11,545 1
noitran/lumen-form-requests

Missing form requests functionality for lumen, ported from laravel framework.

4,750 5
nebo15/lumen.rest

Components for fast building REST API for Lumen

3,797 1
nextdots/api-exceptions

JSON exceptions for your API

385 0
soufiene-slimi/lumen-form-requests

Missing form requests functionality for lumen, ported from laravel framework.

100 0

Version History

Version Released PHP License
1.4.0 ^7.3 MIT
1.3.0 ~7.2 MIT
1.2.4 ~7.1 MIT
1.2.3 ~7.1 MIT
1.2.2 ~7.1 MIT