Installation &amp; setup | laravel-query-builder-rust | Spatie       

 SPATIE  

laravel-query-builder-rust
==========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-query-builder-rust](https://spatie.be/docs/laravel-query-builder-rust/v1)  Installation &amp; setup

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-query-builder-rust/v1) 

  Installation &amp; setup    
- [ Introduction ](https://spatie.be/docs/laravel-query-builder-rust/v1/introduction)
- [ Requirements ](https://spatie.be/docs/laravel-query-builder-rust/v1/requirements)
- [ About us ](https://spatie.be/docs/laravel-query-builder-rust/v1/about-us)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-query-builder-rust/v1/installation-setup)
- [ Support us ](https://spatie.be/docs/laravel-query-builder-rust/v1/support-us)
- [ Questions and issues ](https://spatie.be/docs/laravel-query-builder-rust/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-query-builder-rust/v1/changelog)
- [ Testing ](https://spatie.be/docs/laravel-query-builder-rust/v1/testing)

Features
--------

- [ Filtering ](https://spatie.be/docs/laravel-query-builder-rust/v1/features/filtering)
- [ Sorting ](https://spatie.be/docs/laravel-query-builder-rust/v1/features/sorting)
- [ Including relationships ](https://spatie.be/docs/laravel-query-builder-rust/v1/features/including-relationships)
- [ Selecting fields ](https://spatie.be/docs/laravel-query-builder-rust/v1/features/selecting-fields)

Advanced usage
--------------

- [ Extending query builder ](https://spatie.be/docs/laravel-query-builder-rust/v1/advanced-usage/extending-query-builder)
- [ Pagination ](https://spatie.be/docs/laravel-query-builder-rust/v1/advanced-usage/pagination)
- [ Multi value delimiter ](https://spatie.be/docs/laravel-query-builder-rust/v1/advanced-usage/multi-value-delimiter)
- [ Front-end implementation ](https://spatie.be/docs/laravel-query-builder-rust/v1/advanced-usage/front-end-implementation)

 Installation &amp; setup
========================

###  On this page 

1. [ Typed application configuration ](#content-typed-application-configuration)

Install from Git. The package is not published to crates.io.

```
[dependencies]
laravel = { package = "laravel-rust", version = "=0.1.0", default-features = false, features = ["database-sqlite"] }
spatie-laravel-query-builder = { git = "https://github.com/spatie/laravel-query-builder-rust" }
```

- Cargo downloads Laravel from crates.io and package-tools from its pinned Git revision.
- Configure the application's database connection and migrations normally.
- Execute queries inside a Laravel HTTP request, command or `Application::scope`.

Package settings are caller-owned. Pass `.config(config)` to each builder:

```
use spatie_query_builder::{Config, Parameters};

let config = Config {
    delimiter: "|".into(),
    parameters: Parameters { sort: "order".into(), ..Parameters::default() },
    ..Config::default()
};
```

- Parameter names default to `filter`, `sort`, `include`, `fields`, and `append`, with a comma delimiter.
- Set `parameters.filter` to `None` to read top-level filter parameters.
- `filter_value_splitting_enabled` controls splitting for filters only.
- The three `disable_invalid_*_query_exception` flags ignore unknown filters, sorts or includes without granting access to them. Fields always require an exact allowlist.

Typed application configuration
-----------------------------------------------------------------------------------------------------------------------------------------------------

Register the package-tools provider when multiple handlers share environment-backed settings:

```
use laravel::Application;
use spatie_query_builder::{Config, service_provider};

let app = Application::configure()
    .with_providers(|providers| {
        providers.add(service_provider());
    })
    .create();
```

- Read `laravel::config().section::<Config>().clone()` inside an application context and pass it to `.config(...)`. A handler can also take a native `laravel::config::Section<Config>` argument.
- Application `with_config` callbacks run after provider defaults and can replace or adjust the typed section.
- Query builders never read global configuration implicitly. The provider is optional when you pass settings directly.
- No installation command or generated configuration file is required.

`Config::from_env` reads these variables through Laravel's environment reader:

- `QUERY_BUILDER_DELIMITER` defaults to `,`.
- `QUERY_BUILDER_FILTER_PARAMETER`, `QUERY_BUILDER_SORT_PARAMETER`, `QUERY_BUILDER_INCLUDE_PARAMETER`, `QUERY_BUILDER_FIELDS_PARAMETER`, and `QUERY_BUILDER_APPEND_PARAMETER` default to the corresponding names above.
- `QUERY_BUILDER_FILTER_VALUE_SPLITTING_ENABLED` defaults to `true`.
- `QUERY_BUILDER_DISABLE_INVALID_FILTER_QUERY_EXCEPTION`, `QUERY_BUILDER_DISABLE_INVALID_SORT_QUERY_EXCEPTION`, and `QUERY_BUILDER_DISABLE_INVALID_INCLUDE_QUERY_EXCEPTION` default to `false`.
- `QUERY_BUILDER_CONVERT_FIELD_NAMES_TO_SNAKE_CASE` defaults to `false`.

Invalid boolean values in application configuration fail startup through Laravel's normal environment validation. Set `parameters.filter = None` in code when filters should use top-level parameters.

- The Cargo package name is `spatie-laravel-query-builder`; Rust imports use `spatie_query_builder`.
- The package enables the framework's database API without selecting a driver. Enable `database-sqlite`, `database-mysql`, or `database-postgres` on the application's Laravel dependency.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
