PHPackages                             victormgomes/laravel-query-engine - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. victormgomes/laravel-query-engine

ActiveLibrary[HTTP &amp; Networking](/categories/http)

victormgomes/laravel-query-engine
=================================

Automatically generates dynamic API parameters, strict validation, and optimized queries based on Eloquent Models.

v1.0.0(today)20[1 PRs](https://github.com/VictorMGomes/laravel-query-engine/pulls)MITPHPPHP ^8.3CI failing

Since Jun 22Pushed todayCompare

[ Source](https://github.com/VictorMGomes/laravel-query-engine)[ Packagist](https://packagist.org/packages/victormgomes/laravel-query-engine)[ Docs](https://github.com/victormgomes/laravel-query-engine)[ GitHub Sponsors](https://github.com/sponsors/VictorMGomes)[ RSS](/packages/victormgomes-laravel-query-engine/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (27)Versions (2)Used By (0)

Laravel Query Engine
====================

[](#laravel-query-engine)

Automatically generates dynamic API parameters, strict validation, and optimized queries based on Eloquent Models.

Package Status
--------------

[](#package-status)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b060d73d5a76cc2843817d9e6fcef5ffb682b91a20ec7e183639a5a31d830146/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766963746f726d676f6d65732f6c61726176656c2d71756572792d656e67696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/victormgomes/laravel-query-engine)[![Total Downloads](https://camo.githubusercontent.com/499e711becda640ea50570cb340821a711fd4d0bf90c701152725a9283dc4e74/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766963746f726d676f6d65732f6c61726176656c2d71756572792d656e67696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/victormgomes/laravel-query-engine)[![License](https://camo.githubusercontent.com/7d4fb5fb19582460904bbfe0cf75cdc457187e9d1339758fcd49572c33d1e681/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f766963746f726d676f6d65732f6c61726176656c2d71756572792d656e67696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/victormgomes/laravel-query-engine)

[![PHP Versions](https://camo.githubusercontent.com/c23582b5a48e34936cbf8a4cfd74e39f798662da477fbd40bf2d11a5ab1f35cd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e335f2537435f382e345f2537435f382e352d3737374242342e7376673f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://php.net/)[![Laravel Versions](https://camo.githubusercontent.com/dba2cbca47a4c73b9d6d16d347ab076d5f7aca48b8f1da78e5b3f175fd822789/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e785f2537435f31332e782d3232433535452e7376673f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://laravel.com/)

[![GitHub Tests Action Status](https://camo.githubusercontent.com/d87a03e02506147fdd9baf53dc59326e574ea4aa67cb8d37fe65f8b6fc08e9d3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766963746f726d676f6d65732f6c61726176656c2d71756572792d656e67696e652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/victormgomes/laravel-query-engine/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/be3ec974119ba8102718bad90fd70bf615dd01fcfe156030aa45dcf1047adad0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766963746f726d676f6d65732f6c61726176656c2d71756572792d656e67696e652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/victormgomes/laravel-query-engine/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![GitHub Code Quality Action Status](https://camo.githubusercontent.com/a51056ac0602c0538722469a7cb01251c454f2c11450bf197e1a91c213ab5b11/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766963746f726d676f6d65732f6c61726176656c2d71756572792d656e67696e652f636f64652d7175616c6974792e796d6c3f6272616e63683d6d61696e266c6162656c3d5048505374616e253230253236253230496e736967687473267374796c653d666c61742d737175617265)](https://github.com/victormgomes/laravel-query-engine/actions?query=workflow%3A%22Code+Quality+%26+Static+Analysis%22+branch%3Amain)

Why Use It?
-----------

[](#why-use-it)

This package saves your time and tokens!

Stop writing repetitive boilerplate for every index endpoint. `laravel-query-engine`acts as a seamless bridge between your HTTP requests and Eloquent.

It empowers a single RESTful controller to handle dynamic, infinitely complex API queries. It automatically handles all the heavy lifting—validation, type casting, and query construction—while respecting your model's native configuration.

You get the extreme flexibility of GraphQL, but with the simplicity and performance of standard Laravel REST APIs.

Features
--------

[](#features)

- **Automated Validation:** Generates strict validation rules directly from your database schema.
- **Dynamic Query Building:** Translates validated URL parameters directly into native Eloquent builder actions.
- **Strict Type Casting:** Inspects your schema to accurately cast URL strings into their correct PHP types (integers, booleans, dates).
- **Deep Security:** Natively respects your model's existing visibility configurations to prevent unmapped column exposure.
- **Advanced Querying:** Out-of-the-box support for full-text search, complex date filters, and nested logical groupings.
- **Model-Level Configuration:** Use native PHP attributes directly on your models to securely expose Local Scopes and query aggregations.
- **Exportable Schemas:** Easily export deduplicated filter schemas to generate dynamic frontend UIs or OpenAPI documentation.
- **AI Agent Ready:** Includes an official [Laravel Boost](https://github.com/laravel/boost) skill to automatically teach AI agents (like Claude Code and Cursor) how to use this package in your project.

How It Works
------------

[](#how-it-works)

Pass dynamic query parameters via the URL using standard arrays or JSON.

**The Request:**

```
GET /api/users?filters={"name":{"like":"John"},"status":"active"}&sorts={"created_at":"desc"}&includes={"posts":{}}

```

**What the package executes under the hood:**

```
User::where('name', 'LIKE', '%John%')
    ->where('status', 'active')
    ->orderBy('created_at', 'desc')
    ->with('posts')
    ->paginate();
```

---

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

[](#installation)

1. Install the package via Composer:

```
composer require victormgomes/laravel-query-engine
```

1. Publish the configuration file:

```
php artisan vendor:publish --tag="laravel-query-engine-config"
```

---

Quick Start
-----------

[](#quick-start)

### Step 1: Auto-generate validation rules

[](#step-1-auto-generate-validation-rules)

Annotate your FormRequest with `#[MapQueryEngine(Model::class)]`.

```
// app/Http/Requests/IndexUserRequest.php
use Illuminate\Foundation\Http\FormRequest;
use Victormgomes\LaravelQueryEngine\Attributes\MapQueryEngine;
use App\Models\User;

#[MapQueryEngine(User::class)]
class IndexUserRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }
}
```

It generates the validation rules based on the model schema.

### Step 2: Build the query

[](#step-2-build-the-query)

The package automatically adds powerful new methods directly to all your Eloquent models. You can call these anywhere in your application (such as a Controller or a Service class) by simply passing the validated request:

```
// app/Http/Controllers/UserController.php
use App\Models\User;
use App\Http\Requests\IndexUserRequest;
use Illuminate\Pagination\LengthAwarePaginator;

public function index(IndexUserRequest $request): LengthAwarePaginator
{
    // Pass the request to automatically apply all URL parameters
    return User::paginateQuery($request);
}
```

This returns a `LengthAwarePaginator` with all valid filters, sorts, includes, and pagination automatically applied.

---

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

[](#documentation)

For a deep dive into the features, please read the [Official Documentation](docs/index.md).

---

Credits
-------

[](#credits)

- [Victor M. Gomes](https://github.com/victormgomes)
- [All Contributors](../../contributors)

Support Us
----------

[](#support-us)

If you find this package useful in your day-to-day development, please consider [sponsoring my work](https://github.com/sponsors/VictorMGomes) or leaving a ⭐ on the repository. Your support directly helps keep this project actively maintained and free!

---

Community &amp; Guidelines
--------------------------

[](#community--guidelines)

- [Upgrading Guide](UPGRADING.md)
- [Changelog](CHANGELOG.md)
- [Contributing](CONTRIBUTING.md)
- [Code of Conduct](CODE_OF_CONDUCT.md)
- [Security Policy](SECURITY.md)
- [Support &amp; Help](SUPPORT.md)

---

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.2% 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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20375480?v=4)[Victor M. Gomes](/maintainers/victormgomes)[@VictorMGomes](https://github.com/VictorMGomes)

---

Top Contributors

[![VictorMGomes](https://avatars.githubusercontent.com/u/20375480?v=4)](https://github.com/VictorMGomes "VictorMGomes (65 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")

---

Tags

apieloquentfilterfilteringgraphqljson-apilaravelpaginationqueryquery-builderquery-paramsrelationshipsrestrest-apischemasearchsortsortingtype-safevalidationapisearchlaravelschemavalidationrestgraphqlpaginationeloquentqueryfiltersortREST APIquery builderfilteringJSON-APIsortingRelationshipstype-safeVictor M. Gomeslaravel-query-engine

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/victormgomes-laravel-query-engine/health.svg)

```
[![Health](https://phpackages.com/badges/victormgomes-laravel-query-engine/health.svg)](https://phpackages.com/packages/victormgomes-laravel-query-engine)
```

###  Alternatives

[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.5k](/packages/larastan-larastan)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k28.4M136](/packages/laravel-cashier)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M118](/packages/laravel-mcp)

PHPackages © 2026

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