Differences from PHP | laravel-query-builder-go | Spatie       

 SPATIE  

laravel-query-builder-go
========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-query-builder-go](https://spatie.be/docs/laravel-query-builder-go/v1)  Advanced-usage  Differences from PHP

 Version   v1      

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

  Differences from PHP    
- [ Requirements ](https://spatie.be/docs/laravel-query-builder-go/v1/requirements)
- [ Introduction ](https://spatie.be/docs/laravel-query-builder-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/laravel-query-builder-go/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-query-builder-go/v1/questions-issues)
- [ Testing ](https://spatie.be/docs/laravel-query-builder-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-query-builder-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/laravel-query-builder-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/laravel-query-builder-go/v1/support-us)
- [ About us ](https://spatie.be/docs/laravel-query-builder-go/v1/about-us)

Features
--------

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

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

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

 Differences from PHP
====================

###  On this page 

1. [ Native Go extension points ](#content-native-go-extension-points)
2. [ Sparse models and related fields ](#content-sparse-models-and-related-fields)
3. [ Includes and aggregates ](#content-includes-and-aggregates)
4. [ Input and normalization ](#content-input-and-normalization)
5. [ Soft deletion and releases ](#content-soft-deletion-and-releases)

The PHP implementation is the behavior source. This port also used `spatie/laravel-query-builder-rust` as a reference for allowlist validation, callback boundaries, parsing limits and regression cases. It does not wrap the Rust implementation.

Native Go extension points
--------------------------------------------------------------------------------------------------------------------------------------

Models are the generic type passed to `For`, not class-name strings. You own their tables, column tags and relationships. Filters, sorts and includes accept your functions or method values. There are no package-owned jobs, persistence models or profile classes to replace. Application profiles can be captured by callbacks.

Go has no dynamically named Eloquent scopes or macros. Register them explicitly. Related property and belongs-to filtering use typed native relationship callbacks or explicitly mapped foreign keys. Callback failures are returned as Go errors. Top-level filter scopes protect existing OR conditions from widening an application's constraints.

Sparse models and related fields
--------------------------------------------------------------------------------------------------------------------------------------------------------

Laravel Go v0.1.0 deliberately converts `model.Builder.Select` into a row query. Sparse fields therefore use `Select` and a row DTO. Sparse model reads and sparse included models return explicit errors. There are no relation-name casing conversion settings for a path the framework cannot execute.

The native conversion does not transfer a model query's explicit `.On(conn)` connection to the row query. For sparse queries, select the connection using a database-bearing context or call `.On(conn)` on the returned row query. Model reads retain their native explicit connection.

Includes and aggregates
-----------------------------------------------------------------------------------------------------------------------------

`IncludeRelations` generates parent paths plus top-level count and exists suffixes. `AllowedIncludes` exposes exactly the names you specify. Aggregate columns and callbacks are explicitly allowlisted. Their values load into model-tagged Go fields, not dynamically named attributes. Constrained counts use native `WithCountQuery`. Other constrained aggregates need application-owned queries because this framework version has no equivalent loader.

Input and normalization
-----------------------------------------------------------------------------------------------------------------------------

`FromRequest` reads URL input without consuming bodies. `RequestData` accepts decoded body input explicitly. There is no implicit query/body merge. Malformed URL encoding or brackets return errors, and numeric root keys are rejected. Parsing limits nesting and array indexes. Conflicting parameter shapes are applied in sorted-key order.

Ignored values use Go's type-strict equality, except literal boolean strings also match their booleans. Lists remain lists after ignored values are removed. Null and absent values stay distinct. An empty URL value is an empty string, not a JSON null.

Soft deletion and releases
--------------------------------------------------------------------------------------------------------------------------------------

The framework does not have PHP's global `SoftDeletes` scope. `Trashed` filters an application-owned deletion timestamp on an otherwise unscoped subject. It cannot remove an existing condition.

The first release is v0.1.0. Later releases advance only the patch number, including for deliberate breaking changes. The documentation alias remains `v1`, independently of Go module versioning.

 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)
