PHPackages                             webrium/foxql - 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. webrium/foxql

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

webrium/foxql
=============

Foxdb query builder

4.1.1(4d ago)163384Apache-2.0PHPPHP ^8

Since Apr 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/webrium/foxdb)[ Packagist](https://packagist.org/packages/webrium/foxql)[ RSS](/packages/webrium-foxql/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (6)Versions (52)Used By (0)

FoxDB
=====

[](#foxdb)

[![Webrium FoxDB Cover](https://repository-images.githubusercontent.com/305963460/5261e7d1-7f5a-449a-bad7-8d95fbba1b19)](https://repository-images.githubusercontent.com/305963460/5261e7d1-7f5a-449a-bad7-8d95fbba1b19)

[![Latest Stable Version](https://camo.githubusercontent.com/1e500c0258005f96d59a07efc5e037f562a257d640fee6272c520337ba737459/687474703a2f2f706f7365722e707567782e6f72672f7765627269756d2f666f7864622f76)](https://packagist.org/packages/webrium/foxdb)[![Total Downloads](https://camo.githubusercontent.com/aa435022ca220da3a69302f6926dea7cbce63f9637e7a677166e5e8ab706f1e3/687474703a2f2f706f7365722e707567782e6f72672f7765627269756d2f666f7864622f646f776e6c6f616473)](https://packagist.org/packages/webrium/foxdb)[![License](https://camo.githubusercontent.com/f36893cb3ca6541faa1ad584518a9e8cc3bbcdad01bdcd8032fa908f75a50b55/687474703a2f2f706f7365722e707567782e6f72672f7765627269756d2f666f7864622f6c6963656e7365)](https://packagist.org/packages/webrium/foxdb)[![PHP](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)](https://www.php.net)[![Tests](https://github.com/webrium/foxdb/actions/workflows/tests.yml/badge.svg)](https://github.com/webrium/foxdb/actions/workflows/tests.yml)

**A standalone PHP database library — Query Builder, Eloquent ORM, Schema Builder, Migrations, and Seeders.**

[**webrium.dev**](https://webrium.dev) · [Documentation](https://webrium.dev/docs/v5/database/introduction) · [GitHub](https://github.com/webrium)

---

FoxDB is the database layer of the [Webrium](https://github.com/webrium) framework, available as a standalone package. It gives you a fluent query builder for writing SQL without strings, an Eloquent-style ORM for working with your data as objects, a schema builder for managing your database structure in PHP, and a migration and seeder system for versioning and populating your database. All of this runs on top of PDO with no external dependencies beyond the driver itself.

Supports **MySQL**, **PostgreSQL**, and **SQLite**, with per-driver SQL generation handled internally — write your queries and migrations once.

Requirements
------------

[](#requirements)

- PHP **8.1** or higher
- PDO extension for your chosen database: `pdo_mysql`, `pdo_pgsql`, or `pdo_sqlite`

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

[](#installation)

```
composer require webrium/foxdb
```

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

[](#quick-start)

```
use Foxdb\DB;

DB::addConnection([
    'driver'   => 'mysql',
    'host'     => '127.0.0.1',
    'database' => 'my_db',
    'username' => 'root',
    'password' => 'secret',
]);

// Query builder
$users = DB::table('users')->where('active', 1)->get();

// Eloquent ORM
use Foxdb\Eloquent\Model;

class User extends Model
{
    protected array $fillable = ['name', 'email'];
}

$user = User::create(['name' => 'Ali', 'email' => 'ali@example.com']);
$admins = User::where('role', 'admin')->get();
```

What's Included
---------------

[](#whats-included)

- **Query Builder** — fluent, parameterized queries: selects, joins, aggregates, raw SQL, transactions
- **Eloquent ORM** — models with mass assignment protection, dirty tracking, attribute casting, soft deletes, and full JSON serialization
- **Relations** — `hasOne`, `hasMany`, `belongsTo`, `belongsToMany`, `hasManyThrough`, with lazy and eager loading
- **Collection** — map, filter, sort, chunk, paginate, and JSON-serialize query results
- **Schema Builder** — create and modify tables with a fluent Blueprint API instead of writing DDL by hand
- **Migrations** — version your schema with `up()` / `down()` methods, rollback, and refresh
- **Seeders** — repeatable scripts for populating your database with default or test data
- **Query Log &amp; Hooks** — log every query, measure execution time, detect slow queries, attach `beforeQuery` / `afterQuery` callbacks

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

[](#documentation)

The complete documentation for FoxDB lives at **[webrium.dev/docs/v5/database](https://webrium.dev/docs/v5/database/introduction)**:

- **[Introduction](https://webrium.dev/docs/v5/database/introduction)** — design goals, namespace, standalone setup
- **[Connections](https://webrium.dev/docs/v5/database/connections)** — registering connections, multi-connection, raw SQL, transactions, query log
- **[Query Builder](https://webrium.dev/docs/v5/database/query-builder)** — selects, where conditions, joins, aggregates, writes
- **[Eloquent ORM](https://webrium.dev/docs/v5/database/eloquent-orm)** — models, CRUD, mass assignment, dirty tracking, scopes
- **[Relationships](https://webrium.dev/docs/v5/database/relationships)** — all relation types, eager loading, pivot methods
- **[Collections](https://webrium.dev/docs/v5/database/collections)** — the fluent API for result sets
- **[Casts &amp; Serialization](https://webrium.dev/docs/v5/database/casts-serialization)** — attribute casts, `toArray()`, `toJson()`
- **[Pagination](https://webrium.dev/docs/v5/database/pagination)** — paginating large result sets
- **[Migrations, Schema &amp; Seeders](https://webrium.dev/docs/v5/database/migrations-schema)** — full DDL and data-evolution workflow

The same documentation is also available as plain Markdown in the **[webrium/docs](https://github.com/webrium/docs)** repository.

Running Tests
-------------

[](#running-tests)

```
# Unit tests only — no database needed
vendor/bin/phpunit --testsuite=unit

# Integration tests with SQLite (no server required)
DB_DRIVER=sqlite vendor/bin/phpunit --testsuite=integration

# Integration tests with MySQL
DB_DRIVER=mysql DB_DATABASE=foxdb_test DB_PASSWORD=secret \
    vendor/bin/phpunit --testsuite=integration

# Integration tests with PostgreSQL
DB_DRIVER=pgsql DB_PORT=5432 DB_DATABASE=foxdb_test DB_PASSWORD=secret \
    vendor/bin/phpunit --testsuite=integration

# Run everything
DB_DRIVER=sqlite vendor/bin/phpunit --testsuite=all
```

CI runs all three drivers automatically on every pull request via GitHub Actions.

Part of the Webrium Ecosystem
-----------------------------

[](#part-of-the-webrium-ecosystem)

FoxDB is one of four packages that make up the full [Webrium Framework](https://github.com/webrium/webrium):

- **[`webrium/core`](https://github.com/webrium/core)** — routing, controllers, requests/responses, sessions, validation, and more
- **[`webrium/foxdb`](https://github.com/webrium/foxdb)** — this package
- **[`webrium/view`](https://github.com/webrium/view)** — Blade-compatible templating engine with hybrid static caching
- **[`webrium/console`](https://github.com/webrium/console)** — the `webrium` CLI toolkit

Each is independently usable, except `webrium/console` which is framework-coupled.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance96

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

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

Every ~51 days

Recently: every ~4 days

Total

38

Last Release

4d ago

Major Versions

1.0.2 → 2.0.12022-10-02

1.0.3 → 2.1.32023-10-15

2.1.10 → 3.0.0-beta2024-07-13

3.1.2 → 4.0.02026-06-11

### Community

Maintainers

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

---

Top Contributors

[![benkhalife](https://avatars.githubusercontent.com/u/31080657?v=4)](https://github.com/benkhalife "benkhalife (230 commits)")[![mudassaralichouhan](https://avatars.githubusercontent.com/u/33031651?v=4)](https://github.com/mudassaralichouhan "mudassaralichouhan (7 commits)")

---

Tags

databasemysqlormpdopdo-mysqlphp-libraryphp-query-builderquery-builder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/webrium-foxql/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198741.5k12](/packages/pgvector-pgvector)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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