PHPackages                             byteferry/rql-parser - 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. byteferry/rql-parser

ActiveLibrary[API Development](/categories/api)

byteferry/rql-parser
====================

A PHP parser for parsing the resource query language(RQL) to php data structure

0.1.2(5y ago)29MITPHPPHP &gt;=7.1.0

Since Apr 11Pushed 5y ago2 watchersCompare

[ Source](https://github.com/byteferry/rql-parser)[ Packagist](https://packagist.org/packages/byteferry/rql-parser)[ Docs](http://byteferry.github.io/rql-parser/)[ RSS](/packages/byteferry-rql-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

ByteFerry RQL-Parser
====================

[](#byteferry-rql-parser)

> ByteFerry RQL-Parser is used for parsing the RQL text to the paramaters with PHP array structure for the calling of php methods.

[![Build Status](https://camo.githubusercontent.com/f624cc996a72326c13ff5f539f2cebcf05fc1ec0bc5e320529ac5ac47c71572d/68747470733a2f2f7472617669732d63692e6f72672f6279746566657272792f72716c2d7061727365722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/byteferry/rql-parser)[![StyleCI](https://camo.githubusercontent.com/b9dd55a46887b5fc7bdff4a32a03f904d9f92a76d5cb27d14a4623c597034094/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3335363635393536302f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/356659560?branch=master)[![Codecov branch](https://camo.githubusercontent.com/eb8b4d53d6ac4275d1f16b46102084db25758a61f10a84fb8731bc0d4f192074/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6279746566657272792f72716c2d7061727365722f646576656c6f702e7376673f7374796c653d666c61742d737175617265266c6f676f3d636f6465636f76)](https://codecov.io/github/byteferry/rql-parser)[![Latest Stable Version](https://camo.githubusercontent.com/9f4eb34d9dcdbcbcdba33b67d6d0fe1ec555a0d600e0577b2f008140d0286c92/68747470733a2f2f706f7365722e707567782e6f72672f6279746566657272792f72716c2d7061727365722f76)](//packagist.org/packages/byteferry/rql-parser)[![Total Downloads](https://camo.githubusercontent.com/9da390544cfe50118318cbc071660c4c9a7a63733fd376ec3e883dde41cc038e/68747470733a2f2f706f7365722e707567782e6f72672f6279746566657272792f72716c2d7061727365722f646f776e6c6f616473)](//packagist.org/packages/byteferry/rql-parser)[![License](https://camo.githubusercontent.com/4fce6d4618e561f9d657174b6ab4c3fb9e054d4239ad6db09adc71f8dd94f3ca/68747470733a2f2f706f7365722e707567782e6f72672f6279746566657272792f72716c2d7061727365722f6c6963656e7365)](//packagist.org/packages/byteferry/rql-parser)

[中文(Chinese)](https://github.com/byteferry/rql-parser/blob/master/README.cn.md)

This library consists of the following parts:

- lexer for tokenization RQL code
- parser for creating abstract syntax tree
- builder using simplized ABNF of RQL

Features
--------

[](#features)

- High performance. The size of source code is less than 60KB.
- It is fully according the compile specification.
- Friendly for development with the checking of RQL grammer.
- Support the both reading and writing query.
- Support `filter` `sort` `search` and `pagination`
- Fully tested with phpUnit.
- Zero dependencies.

Why RQL
-------

[](#why-rql)

- For the same data, RQL has much fewer bytes than JSON.
- Simple and easy to learn.
- RQL will make the API interface more flexible
- RQL is more suitable for small and medium-sized projects than GraphQL.
- RQL can save you more development time.

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

[](#installation)

```
$ composer requrire byteferry/rql-Parser
```

Usage
-----

[](#usage)

- parser a full query

```
use ByteFerry/RqlParser/Parser;

    $rql_string = 'any(User,columns(id,name,age,gender,address),filter(eq(age,19)))';
    try{
        $query = Parser::parse( $rql_string);
    }catch(\Exception $e){
        // will catch  errror of parse or grammer checking.
    }
```

if sucess, it will return a QueryInterface.

- parser a query segment of RQL query

```
use ByteFerry/RqlParser/Parser;

    $rql_string = 'filter(eq(age,19))';
    try{
        $query = Parser::parse( $rql_string, true);
    }catch(\Exception $e){
        // will catch  errror of parse or grammer checking.
    }
```

Here is a complex example. (Not a real query, but returns all properties)

```
        $rql_str= 'all(User,aggr(id,name,age,gender,address,avg(age)),filter(is(created_at, null()), search(Jhon),sort(-id,+age),having(gt(sum(amount),0)),limit(0,20)))'; //,    //,
        $result = Parser::parse($rql_str);
        // Returns：
        /** array (
             0 =>
             ByteFerry\RqlParser\Query::__set_state(array(
                'container' =>
               array (
                 'resource' => 'User',
                 'columns' =>
                 array (
                   0 => 'id',
                   1 => 'name',
                   2 => 'age',
                   3 => 'gender',
                   4 => 'address',
                   5 => 'avg(age)',
                 ),
                 'columns_operator' => 'aggr',
                 'group_by' =>
                 array (
                   0 => 'id',
                   1 => 'name',
                   2 => 'age',
                   3 => 'gender',
                   4 => 'address',
                 ),
                 'filter' =>
                 array (
                   0 => ' created_at is null ',
                 ),
                 'paramaters' =>
                 array (
                   'created_at' => NULL,
                   'sum(amount)' => '0',
                 ),
                 'search' => 'Jhon%',
                 'sort' =>
                 array (
                   0 =>
                   array (
                     0 => 'id',
                     1 => 'DESC',
                   ),
                   1 =>
                   array (
                     0 => 'age',
                     1 => 'ASC',
                   ),
                 ),
                 'having' =>
                 array (
                   0 => ' sum(amount) > 0 ',
                 ),
                 'limit' =>
                 array (
                   0 => '0',
                   1 => '20',
                 ),
                 'operator' => 'all',
                 'query_type' => 'Q_READ',
               ),
             )),
           )

        */
```

We could see that the parser add groupby automatically, and returns the property parematers for validation.

Documentation
-------------

[](#documentation)

[RQL Documentation](https://byteferry.github.io/rql-parser/#/en-us/)

#### Contribution

[](#contribution)

1. Fork the repository
2. Create Feat\_xxx branch
3. Commit your code
4. Create Pull Request

### Donation

[](#donation)

If you find this project useful, you can buy author a glass of juice 🍹

[![donate](https://raw.githubusercontent.com/BardoQi/bmc/master/myqr_en_sm.png)](https://raw.githubusercontent.com/BardoQi/bmc/master/myqr_en_sm.png)

### License

[](#license)

MIT

Copyright \[2020\] ByteFerry [byteferry@qq.com](ByteFerry@qq.com)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~16 days

Total

3

Last Release

1829d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/48158992?v=4)[byteferry](/maintainers/byteferry)[@byteferry](https://github.com/byteferry)

---

Top Contributors

[![byteferry](https://avatars.githubusercontent.com/u/48158992?v=4)](https://github.com/byteferry "byteferry (24 commits)")[![BardoQi](https://avatars.githubusercontent.com/u/409367?v=4)](https://github.com/BardoQi "BardoQi (2 commits)")

---

Tags

apiparserrqlresource-query-language

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/byteferry-rql-parser/health.svg)

```
[![Health](https://phpackages.com/badges/byteferry-rql-parser/health.svg)](https://phpackages.com/packages/byteferry-rql-parser)
```

###  Alternatives

[nathanmac/parser

Simple PHP Parser Utility Library for API Development

2151.0M3](/packages/nathanmac-parser)[art4/json-api-client

JSON API client

139791.3k7](/packages/art4-json-api-client)[orisai/object-mapper

Raw data mapping to validated objects

1133.5k2](/packages/orisai-object-mapper)

PHPackages © 2026

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