PHPackages                             drewlabs/rest-query - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. drewlabs/rest-query

AbandonedArchivedLibrary[API Development](/categories/api)

drewlabs/rest-query
===================

REST service query implementation

v0.1.22(3y ago)0281MITPHPPHP &gt;=7.2

Since Apr 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/azandrew-sidoine/rest-query)[ Packagist](https://packagist.org/packages/drewlabs/rest-query)[ RSS](/packages/drewlabs-rest-query/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

REST Query
==========

[](#rest-query)

This library provides a client side implementation of RESTful services query (similar to graphql) that allows developpers to easily customize data requested from web resources and directly sending complex query parameters to REST service.

**Requirements**The library only works with compatible web services. Therefore, developpers must provides an implementation that parses, compiles and process query send to the service.

Installation
------------

[](#installation)

Using composer PHP package manager:

> composer require drewlabs/rest-query

Usage
-----

[](#usage)

### Query builder

[](#query-builder)

The library comes with a query builder class that provides a fluent interface for building and compiling queries. An example is as follow:

```
use Drewlabs\RestQuery\QueryBuilder;

// ...

// Building the query and using the query builder fluent API
$builder = QueryBuilder::new()
            ->eq('title', 'Lorem Ipsum')
            ->neq('id', 10)
            ->where(function (QueryBuilder $builder) {
                return $builder->in('tags', ['I', 'L', 'F'])
                    ->gt('likes', 120)
                    ->gte('groups', 10);
            });

// Compiling the query output to JSON string
$result = $builder->json();
```

As seen above, the API comes with numerous fluent methods for defining query intention:

- eq

The `eq` method allow developpers to build a `COLUMN=VALUE` like query:

```
$result = QueryBuilder::new()->eq('title', 'Lorem Ipsum')->getQuery(); // ['where' => [['title, '=', 'Lorem Ipsum']]]
```

- neq

The `neq` is the inverse of the `eq` query method:

```
$result = QueryBuilder::new()->neq('title', 'Lorem Ipsum')->getQuery(); // ['where' => [['title, ', 'Lorem Ipsum']]]
```

- lte / lt

The `lte` and `lt` respectively allow developper to construct a query that check if a column value is less than (less than or equal to) a given value.

```
$result = QueryBuilder::new()->lt('title', 'Lorem Ipsum')->getQuery(); // ['where' => [['title, 'gt('title', 'Lorem Ipsum')->getQuery(); // ['where' => [['title, '>', 'Lorem Ipsum']]]
$result = QueryBuilder::new()->gte('title', 'Lorem Ipsum')->getQuery(); // ['where' => [['title, '>=', 'Lorem Ipsum']]]
```

- in

The `in` clause search for value that exists in a list of provided values:

```
$result = QueryBuilder::new()->in('rates', [3, 3.5, 9])->getQuery(); // ['in' => [['title, [3, 3.5, 9]]]]
```

- exists

The `exists` clause allow to query for relationship existance in the database.

```
$result = QueryBuilder::new()->exists('comments')->getQuery(); // ['has' => [['comments']]]
$result = QueryBuilder::new()->exists('comments', new SubQuery('where', ['likes', '>', 1000]))->getQuery(); // ['has' => [['column' => 'comments', 'method' => ['params' => ['likes', '>', 1000], 'method' => 'where' ]]]]
```

- sort

The `sort` clause allow developpers to apply a sort by `column` on the result set:

**Note** The sort order is defined by an integer value. Any value greater than `0` get converted to `ASC` while any value less than `0` is converted to `DESC`

```
$result = QueryBuilder::new()->sort('created_at', -1)->getQuery(); // ['sort' => ['by' => 'created_at', 'order' => 'DESC']]
```

- select

The `select` clause allows developpers to specify the list of columns to select from the query server:

```
$columns = QueryBuilder::new()->eq('title', 'Lorem Ipsum')->select('*', 'comments')->getColumns(); // ['*', 'comments']
```

The REST query client
---------------------

[](#the-rest-query-client)

The REST query client is an implementation similar to the query language from `drewlabs/database` library that provides 4 overloaded methods `select()`, `update()`, `delete()` and `create()`, sort sending CRUD action to endpoint servers.

It required `drewlabs/curl-rest-client` library for actually doing the http request to server. Therefore in order to use the rest query client, developpers are required to execute the following command to install the required dependencies:

> composer require drewlabs/curl-rest-client

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

4

Last Release

1133d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48c4973d500c7f4233d5ceacab51a57208d5fb60b0f95ae60264cf92380d0534?d=identicon)[azandrew-sidoine](/maintainers/azandrew-sidoine)

---

Top Contributors

[![azandrew-sidoine](https://avatars.githubusercontent.com/u/23530515?v=4)](https://github.com/azandrew-sidoine "azandrew-sidoine (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/drewlabs-rest-query/health.svg)

```
[![Health](https://phpackages.com/badges/drewlabs-rest-query/health.svg)](https://phpackages.com/packages/drewlabs-rest-query)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
