PHPackages                             simsoft/fliq - 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. simsoft/fliq

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

simsoft/fliq
============

FLIQ — Fast, Lightweight, Independent Query Builder. High-performance Active Record ORM for MySQL/MariaDB, PostgreSQL, and SQLite. Zero-allocation query builder, nested eager loading, soft deletes, and N+1 detection built-in.

2.0.3(1mo ago)191MITPHPPHP ^8.4CI passing

Since May 20Pushed 1mo agoCompare

[ Source](https://github.com/sim-soft/fliq)[ Packagist](https://packagist.org/packages/simsoft/fliq)[ RSS](/packages/simsoft-fliq/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (8)Dependencies (14)Versions (11)Used By (1)

FLIQ
====

[](#fliq)

**F**ast, **L**ightweight, **I**ndependent **Q**uery Builder

[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://github.com/sim-soft/fliq/blob/main/LICENSE)[![PHP 8.4+](https://camo.githubusercontent.com/3a1b280ab7672f9ae08c93a083aa42ce8d0c82ff079314d77f5fea924e84927c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d3838393242462e737667)](https://www.php.net/releases/8.4/en.php)[![Docs](https://camo.githubusercontent.com/3c95f812dce10ccc25bfad56943815d943ac08491a022a8b1ca484d3c2ec0ed3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f63732d6f6e6c696e652d677265656e2e737667)](https://sim-soft.github.io/fliq/)

A high-performance Active Record / ORM for MySQL, MariaDB, PostgreSQL, and SQLite. Zero framework dependencies, minimal footprint, maximum speed.

📖 [Documentation](https://sim-soft.github.io/fliq/) · [GitHub](https://github.com/sim-soft/fliq)

```
use Simsoft\DB\Model;

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

// Query with fluent builder
$users = User::find()
    ->where('status', 'active')
    ->with('posts.comments')  // nested eager loading
    ->orderBy('name')
    ->get();

// CRUD
$user = new User(['name' => 'John', 'email' => 'john@example.com']);
$user->save();
```

Why FLIQ?
---------

[](#why-fliq)

The name says it all — **F**ast, **L**ightweight, **I**ndependent **Q**uery Builder.

- **Fast** — One object per query, zero-allocation fast path, prepared statement caching. No other PHP ORM builds query this lean.
- **Lightweight** — ~100KB install size, zero dependencies. No service containers, no config files, no boot process.
- **Independent** — Standalone library with no framework coupling. One `composer require`, one `Connection::add()` call, done.
- **Query Builder** — Fluent, expressive API that compiles directly to optimized SQL without intermediate object layers.

When NOT to Choose FLIQ
-----------------------

[](#when-not-to-choose-fliq)

- You need MSSQL or Oracle support
- You need schema migrations (use [Phinx](https://phinx.org/) or [doctrine/migrations](https://www.doctrine-project.org/projects/migrations.html))
- You need a Data Mapper pattern (use Doctrine or Cycle ORM)
- You need a massive ecosystem of community packages (use Eloquent)

For a detailed feature-by-feature comparison with Eloquent, Doctrine, Yii3, Cycle ORM, and Propel, see the [Comparison Guide](docs/07-COMPARISON.md).

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

[](#requirements)

- PHP 8.4+
- MySQL 5.7+ / MariaDB 10.3+ / PostgreSQL 12+ / SQLite 3.39+
- ext-pdo (required) or ext-mysqli (optional alternative for MySQL)

Install
-------

[](#install)

```
composer require simsoft/fliq
```

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

[](#quick-start)

### 1. Configure Connection

[](#1-configure-connection)

```
require "vendor/autoload.php";

use Simsoft\DB\Connection;

Connection::add('mysql', [
    'driver' => 'mysqli',
    'host' => 'localhost',
    'database' => 'my_app',
    'username' => 'root',
    'password' => '',
    'charset' => 'utf8mb4',
]);
```

### 2. Define a Model

[](#2-define-a-model)

```
use Simsoft\DB\Model;
use Simsoft\DB\Relation;

class Post extends Model
{
    protected string $table = 'post';
    protected array $fillable = ['title', 'content', 'user_id'];

    public function author(): Relation
    {
        return $this->hasOne(User::class, ['id' => 'user_id']);
    }

    public function comments(): Relation
    {
        return $this->hasMany(Comment::class, ['post_id' => 'id']);
    }
}
```

### 3. Use It

[](#3-use-it)

```
// Find by primary key
$post = Post::findByPk(1);

// Query with conditions
$posts = Post::find()
    ->where('status', 'published')
    ->with('author', 'comments')
    ->orderBy('created_at', 'DESC')
    ->limit(10)
    ->get();

// Create
$post = new Post(['title' => 'Hello', 'content' => 'World']);
$post->save();

// Update
$post->title = 'Updated';
$post->save();

// Delete
$post->delete();
```

Features
--------

[](#features)

- [Zero-Allocation Query Building](#zero-allocation-query-building)
- [Nested Eager Loading](#nested-eager-loading)
- [Conditional Queries](#conditional-queries)
- [JSON Column Queries](#json-column-queries)
- [Multi-Column Conditions](#multi-column-conditions)
- [Transactions](#transactions)
- [Soft Deletes &amp; Timestamps](#soft-deletes--timestamps)
- [Model Events](#model-events)
- [Query Result Caching](#query-result-caching)
- [Read/Write Connection Splitting](#readwrite-connection-splitting)
- [Development Tools](#development-tools)

---

### Zero-Allocation Query Building

[](#zero-allocation-query-building)

The most common query patterns (`where`, `in`, `like`, `between`, `orderBy`, `select`) build SQL strings directly without creating intermediate objects. One `ActiveQuery` object handles everything.

### Nested Eager Loading

[](#nested-eager-loading)

```
// 4 queries total, regardless of record count
$users = User::find()->with('posts.comments.author')->get();
```

### Conditional Queries

[](#conditional-queries)

```
$users = User::find()
    ->when($search !== null, fn($q) => $q->like('name', "%$search%"))
    ->unless($isAdmin, fn($q) => $q->where('published', true))
    ->get();
```

### JSON Column Queries

[](#json-column-queries)

```
// Auto JSON extraction via -> notation (works in where, in, orderBy, etc.)
User::find()->where('preferences->dining->meal', 'salad')->get();
User::find()->in('preferences->dining->meal', ['pasta', 'salad'])->get();
User::find()->orderBy('meta->score', 'DESC')->get();

// JSON methods
User::find()->jsonContains('tags', 'php')->get();            // array contains value
User::find()->jsonNotContains('tags', 'java')->get();        // array excludes value
User::find()->jsonHas('meta->address')->get();               // key exists
User::find()->jsonMissing('meta->foo')->get();               // key missing
User::find()->jsonLength('tags', '>', 2)->get();             // array length

// Aliases (whereJson* style)
User::find()->whereJsonContains('tags', 'php')->get();
User::find()->whereJsonDoesntContain('tags', 'java')->get();
User::find()->whereJsonContainsKey('meta->address')->get();
User::find()->whereJsonDoesntContainKey('meta->foo')->get();
User::find()->whereJsonLength('tags', '>', 2)->get();
```

### Multi-Column Conditions

[](#multi-column-conditions)

```
// Match ANY column (OR logic)
User::find()->whereAny(['name', 'email', 'phone'], 'like', '%john%')->get();
// → WHERE (name LIKE ? OR email LIKE ? OR phone LIKE ?)

// Match ALL columns (AND logic)
Post::find()->whereAll(['title', 'body'], 'like', '%Laravel%')->get();
// → WHERE (title LIKE ? AND body LIKE ?)

// Match NONE of the columns
Post::find()->whereNone(['title', 'body'], 'like', '%spam%')->get();
// → WHERE NOT (title LIKE ? OR body LIKE ?)
```

### Transactions

[](#transactions)

```
User::transaction(function () {
    $user = new User(['name' => 'John', 'email' => 'john@example.com']);
    $user->save();

    $post = new Post(['user_id' => $user->id, 'title' => 'First Post']);
    $post->save();

    return true; // commit
});
// Return false (or don't return true) to roll back
```

### Soft Deletes &amp; Timestamps

[](#soft-deletes--timestamps)

```
class User extends Model
{
    use SoftDeletes, Timestamps;
    protected string $table = 'user';
}

$user->delete();    // sets deleted_at
$user->restore();   // clears deleted_at
User::withTrashed()->get(); // includes deleted
```

### Model Events

[](#model-events)

```
// Register event listeners
User::on('creating', function (User $user) {
    $user->slug = strtolower($user->name);
});

User::on('deleting', function (User $user) {
    if ($user->role === 'admin') return false; // cancel deletion
});

// Observer class
User::observe(new AuditObserver());
```

### Query Result Caching

[](#query-result-caching)

```
use Simsoft\DB\Cache\QueryCache;
use Simsoft\DB\Cache\ArrayCache;

QueryCache::setDriver(new ArrayCache());

// Cache results for 60 seconds
$users = User::find()->where('active', 1)->cache(60)->get();
```

### Read/Write Connection Splitting

[](#readwrite-connection-splitting)

```
Connection::add('mysql', [
    'driver' => 'mysqli',
    'database' => 'myapp',
    'read' => ['host' => 'replica.db.internal'],
    'write' => ['host' => 'primary.db.internal'],
]);
// SELECT auto-routes to read, INSERT/UPDATE/DELETE to write
```

### Development Tools

[](#development-tools)

```
// N+1 detection
QueryMonitor::enable();

// Query logging with timing
QueryLogger::enable();
$queries = QueryLogger::getQueries();
$slowest = QueryLogger::getSlowestQuery();

// Index advisor
IndexAdvisor::suggestSQL();
```

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

[](#documentation)

📖 **[Read the full documentation](https://sim-soft.github.io/fliq/)**

1. [Getting Started](docs/01-GETTING-STARTED.md) — Connections, drivers, raw queries, DB facade, monitoring
2. [Query Builder](docs/02-QUERY-BUILDER.md) — Fluent API, conditions, joins, JSON, aggregation, scopes, unions
3. [Active Record](docs/03-ACTIVE-RECORD.md) — Models, CRUD, casting, hooks, events, soft deletes, timestamps
4. [Relations](docs/04-RELATION.md) — hasOne, hasMany, via, viaTable, eager loading, whereHas
5. [Advanced Features](docs/05-ADVANCED-FEATURES.md) — Caching, pagination, global scopes, batch operations, read/write split
6. [Collections](docs/06-COLLECTIONS.md) — Lazy iteration, filter, map, reduce, indexBy, groupBy, batch processing
7. [Comparison](docs/07-COMPARISON.md) — Feature comparison with Eloquent, Doctrine, Yii3, Cycle, Propel
8. [Cheatsheet](docs/08-CHEATSHEET.md) — Quick reference for all common operations

License
-------

[](#license)

FLIQ is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance94

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.5% 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 ~5 days

Total

7

Last Release

31d ago

Major Versions

1.0.4 → 2.0.02026-05-30

PHP version history (2 changes)1.0.2PHP ^8.1

2.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c3e6315469b56ed1797318e31e05bcddb12dba268488a2fb0cd2b43971c9ac3?d=identicon)[vzangloo](/maintainers/vzangloo)

---

Top Contributors

[![vzangloo](https://avatars.githubusercontent.com/u/1908200?v=4)](https://github.com/vzangloo "vzangloo (25 commits)")[![sim-soft](https://avatars.githubusercontent.com/u/118705222?v=4)](https://github.com/sim-soft "sim-soft (9 commits)")

---

Tags

persistencedatabaseormmysqlpostgresqlmariadbpdomodelactive-recordquery buildereager-loadingsoft-deleteeloquent-alternativephp orm

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/simsoft-fliq/health.svg)

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

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58925.9M54](/packages/scienta-doctrine-json-functions)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

826.1k](/packages/tommyknocker-pdo-database-class)[longitude-one/doctrine-spatial

Doctrine multi-platform support for spatial types and functions, compliant with Doctrine 2.19, 3.1, and dev ones (3.2 and 4.0).

911.7M1](/packages/longitude-one-doctrine-spatial)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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