PHPackages                             switon/query - 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. [Database &amp; ORM](/categories/database)
4. /
5. switon/query

ActiveLibrary[Database &amp; ORM](/categories/database)

switon/query
============

Fluent read SQL builder with joins, pagination, and shard-aware execution for Switon Framework

v1.0.0(1mo ago)062MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/query)[ Packagist](https://packagist.org/packages/switon/query)[ Docs](https://github.com/switon-php/query)[ RSS](/packages/switon-query/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (8)Versions (2)Used By (2)

Switon Query Package
====================

[](#switon-query-package)

[![Query CI](https://camo.githubusercontent.com/4a49833553d70df1526e16a0a3277dce88f660632af7f72e7a6cb7624dfb26f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f71756572792f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d51756572792532304349)](https://github.com/switon-php/query/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's fresh-query and shard-aware SQL layer for fluent filters, pagination, and merged reads.

Highlights
----------

[](#highlights)

- **Fresh query objects:** `QueryBuilderInterface::from()` starts a fresh query each time.
- **Fluent read building:** `QueryInterface` chains filters, joins, ordering, grouping, limits, and pagination.
- **Shard-aware execution:** `Query` can resolve shards and merge multi-shard results.
- **Explicit table context:** `Table` carries table name and connection together when routing matters.
- **Paging support:** `Paginator` keeps page boundaries explicit.

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

[](#installation)

```
composer require switon/query
```

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

[](#quick-start)

```
use Switon\Core\Attribute\Autowired;
use Switon\Query\QueryBuilderInterface;
use Switon\Query\PaginatorInterface;

final class UserService
{
    #[Autowired] protected QueryBuilderInterface $queryBuilder;

    public function listAction(int $page = 1): PaginatorInterface
    {
        return $this->queryBuilder->from('users')
            ->where(['status' => 1])
            ->orderBy(['created_at' => SORT_DESC])
            ->paginate($page, 10);
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance87

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

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

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc0f20ad15b0ae9fbf9c6e2cd3008692b0c88a877ec8d3e0119211314bf86fc8?d=identicon)[switon](/maintainers/switon)

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (5 commits)")

---

Tags

databasequery-buildersqlswitondatabasesqlquery builderswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/switon-query/health.svg)

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

###  Alternatives

[usmanhalalit/pixie

A lightweight, expressive, framework agnostic query builder for PHP.

6882.2M16](/packages/usmanhalalit-pixie)[foolz/sphinxql-query-builder

A PHP query builder for SphinxQL and ManticoreQL with MySQLi and PDO drivers.

3232.2M34](/packages/foolz-sphinxql-query-builder)[cycle/database

DBAL, schema introspection, migration and pagination

71777.8k63](/packages/cycle-database)[opis/database

A database abstraction layer over PDO, that provides a powerful and intuitive query builder, bundled with an easy to use schema builder

10085.4k3](/packages/opis-database)[jasny/persist-sql-query

SQL Query builder and parser

33524.4k5](/packages/jasny-persist-sql-query)[fobia/laravel-sphinx

A Laravel query builder for SphinxQL

32138.0k](/packages/fobia-laravel-sphinx)

PHPackages © 2026

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