PHPackages                             zaruto/scramble-spatie-query-builder - 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. zaruto/scramble-spatie-query-builder

ActiveLibrary[API Development](/categories/api)

zaruto/scramble-spatie-query-builder
====================================

This is the Scramble extension, which detects the usage of the Spatie query builder and adds applicable query parameters to the openapi definitions

v1.0.1(3mo ago)040↓88%MITPHPPHP ^8.3

Since Mar 26Pushed 3mo agoCompare

[ Source](https://github.com/zaruto/scramble-spatie-query-builder)[ Packagist](https://packagist.org/packages/zaruto/scramble-spatie-query-builder)[ RSS](/packages/zaruto-scramble-spatie-query-builder/feed)WikiDiscussions main Synced 3w ago

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

Scramble extension for Spatie Query Builder
===========================================

[](#scramble-extension-for-spatie-query-builder)

[![Preview](./.github/preview.png)](./.github/preview.png)

Introduction
------------

[](#introduction)

This is the Scramble extension, which detects the usage of the Spatie query builder in your api routes and automatically adds applicable query parameters to the openapi definition.

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

[](#installation)

After you publish the package on Packagist:

```
composer require zaruto/scramble-spatie-query-builder

```

Until the package is published, install it directly from your GitHub repository:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/zaruto/scramble-spatie-query-builder.git"
        }
    ],
    "require": {
        "zaruto/scramble-spatie-query-builder": "dev-main"
    }
}
```

Then run:

```
composer update zaruto/scramble-spatie-query-builder
```

Supported baseline:

- PHP `^8.3`
- `dedoc/scramble` `^0.13.16`
- `spatie/laravel-query-builder` `^7.0.1`
- Laravel 12 test/dev stack

Usage
-----

[](#usage)

1. Register the extension in your `config/scramble.php` file.

```
'extensions' => [
    // ...
    \Zaruto\ScrambleSpatieQueryBuilder\AllowedFieldsExtension::class,
    \Zaruto\ScrambleSpatieQueryBuilder\AllowedSortsExtension::class,
    \Zaruto\ScrambleSpatieQueryBuilder\AllowedFiltersExtension::class,
    \Zaruto\ScrambleSpatieQueryBuilder\AllowedIncludesExtension::class,
//    \Zaruto\ScrambleSpatieQueryBuilder\AllowedFilterModesExtension::class
],
```

2. Use Spatie Query Builder in your controller or route action as usual.

```
