noitran/rql

RQL - Resource Query Language package for laravel / lumen projects
14 2
Install
composer require noitran/rql
Latest Version:0.2.0
PHP:>=7.3
License:MIT
Last Updated:Sep 4, 2019
Links: GitHub  ·  Packagist
Maintainer: noitran

RQL - Resource Query Language Package

About

Package allows to use Resource Query Language (RQL) with Laravel's Eloquent ORM. Providers a simple and light-weight API for adding dynamic querying capabilities to HTTP based applications. Package functions as connector between HTTP requests and ORM. Currently only Eloquent Processor is included, but pacakge capabilities can be easly extended by adding new Processor.

Install

  • Install as composer package
$ composer require noitran/rql

Usage

use Noitran\RQL\Tests\Stubs\Models\User;
use Noitran\RQL\ExprQueue;
use Noitran\RQL\Processors\EloquentProcessor;

// Getting builder instance of model, or builder 
// instance from noitran/repositories also can be passed.
$builder = User::query();

$queue = new ExprQueue();

// Creating expression
$exprClasses = $this->queue->enqueue(
	new \Noitran\RQL\Expressions\EqExpr(null, 'name', 'John')
);

// Attaching expression into builder
$query = (new EloquentProcessor($this->builder))->process($exprClasses);

// Thats it! Expression has been applied. Can be checked by dumping query.
// Example:
dd($query->toSql());

// Dumps attached expression to sql:
// select * from "users" where "name" = ?

All samples can be viewed in testfile: Noitran\RQL\Tests\Processors\EloquentProcessorTest

Todo

  • Add request / input parsers.
  • Improve relation / column bindings.
  • Improve docs and add more samples.

Related Packages

noitran/micro-repositories

Repositories package for laravel / lumen projects

2 1
fathomminds/php-rest-models

Framework independent PHP REST models with schema validation and multiple databa...

908 2
dataworkstr/revisionable

Nice and easy way to handle revisions of your MongoDB.

86 1
azen/apify-lumen

A pretty library to help developers build RESTful APIs lightly, quickly and prop...

13 0
suren/laravel-mongo-model-schema

Make mongo data saving and retrieving match defined schemas for Laravel. Support...

2,452 7