PHPackages                             hiblaphp/database - 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. hiblaphp/database

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

hiblaphp/database
=================

The complete asynchronous, framework-agnostic database layer toolkit for the Hibla Ecosystem (Query Builder, Migrations, and Seeders)

1.0.0-beta.1(today)00MITPHP ^8.4

Since Jun 9Pushed todayCompare

[ Source](https://github.com/hiblaphp/database)[ Packagist](https://packagist.org/packages/hiblaphp/database)[ GitHub Sponsors](https://github.com/hiblaphp)[ GitHub Sponsors](https://github.com/rcalicdan)[ RSS](/packages/hiblaphp-database/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Hibla Database
==============

[](#hibla-database)

The official documentation for the Hibla PHP database ecosystem: a fully asynchronous, framework-agnostic database layer built on fibers/promises and non-blocking I/O.

Table of Contents
-----------------

[](#table-of-contents)

- [Overview](#overview)
- [Quick Start](#quick-start)
- [Packages](#packages)
- [Requirements](#requirements)
- [Supported Drivers](#supported-drivers)
- [Installation](#installation)
    - [Query Builder Only](#query-builder-only)
    - [With Schema Manager](#with-schema-manager)
- [Configuration](#configuration)
    - [The Config File](#the-config-file)
    - [Environment Variables](#environment-variables)
    - [Custom Config Locations](#custom-config-locations)
- [Getting Started](#getting-started)
    - [Bootstrapping the Connection](#bootstrapping-the-connection)
    - [Using the DB Facade](#using-the-db-facade)
        - [Closing Connections](#closing-connections)
        - [Testing with setSqlClient](#testing-with-setsqlclient)
        - [Dynamic Connection Management](#dynamic-connection-management)
        - [Raw Queries](#raw-queries)
    - [Dependency Injection Mode](#dependency-injection-mode)
        - [Choosing an Interface](#choosing-an-interface)
        - [Constructor Injection](#constructor-injection)
        - [Registering with a DI Container](#registering-with-a-di-container)
- [Query Builder](#query-builder)
    - [Reading Data](#reading-data)
        - [Fetching Data](#fetching-data)
        - [Selecting Columns](#selecting-columns)
        - [Where Conditions](#where-conditions)
        - [Advanced Conditions](#advanced-conditions)
        - [Raw Expressions](#raw-expressions)
        - [Conditional Query Building](#conditional-query-building)
        - [JSON Conditions](#json-conditions)
        - [Joins](#joins)
        - [Grouping and Ordering](#grouping-and-ordering)
        - [Aggregates and Existence](#aggregates-and-existence)
        - [Pagination](#pagination)
    - [Writing Data](#writing-data)
        - [Inserting Data](#inserting-data)
        - [Updating Data](#updating-data)
        - [Deleting Data](#deleting-data)
    - [Advanced](#advanced)
        - [Processing Large Datasets (Streams vs Chunks)](#processing-large-datasets-streams-vs-chunks)
        - [Transactions](#transactions)
        - [Common Table Expressions](#common-table-expressions)
        - [Pessimistic Locking](#pessimistic-locking)
        - [Debugging](#debugging)
- [Schema Manager](#schema-manager)
    - [Installing the Schema Manager](#installing-the-schema-manager)
    - [Initializing](#initializing)
    - [Custom CLI Entry Point](#custom-cli-entry-point)
    - [CLI Reference](#cli-reference)
    - [Migrations](#migrations)
        - [Creating Migration Files](#creating-migration-files)
        - [Writing Migrations](#writing-migrations)
        - [Blueprint Column Types](#blueprint-column-types)
        - [Running Migrations](#running-migrations)
        - [Rolling Back](#rolling-back)
        - [Migration Status](#migration-status)
        - [Schema Dump](#schema-dump)
    - [Seeders](#seeders)
        - [Creating Seeders](#creating-seeders)
        - [Writing Seeders](#writing-seeders)
        - [Running Seeders](#running-seeders)
    - [Multiple Connections](#multiple-connections)
    - [Safe Mode](#safe-mode)
- [License](#license)

---

Here is the updated, highly engaging **Overview** section for your main README, written strictly in pure Markdown (no HTML).

It is designed to immediately sell the practical value of the library by showing how it solves the traditional "async vs. convenience" compromise in PHP:

---

Overview
--------

[](#overview)

Hibla Database is an asynchronous, framework-agnostic database layer for modern PHP 8.4+. It is built specifically for long-running, high-concurrency environments (such as Swoole, RoadRunner, or Workerman) and standalone microframeworks (like Slim or Leaf).

This is not a heavy, blocking ORM. It is a highly optimized, non-blocking database lifecycle suite (Query Builder + Schema CLI) designed to be composed into whatever architecture your application needs.

### Why Use this Library?

[](#why-use-this-library)

Historically, PHP developers building high-concurrency applications had to make a painful compromise: either write raw, low-level SQL strings over raw async socket drivers (excellent performance, terrible developer experience), or pull in a bloated full-stack monolith just to get decent database and migration tooling.

Hibla eliminates this compromise completely by delivering three core pillars:

- **True Asynchronous Power:** By operating directly over non-blocking socket streams instead of blocking PDO, Hibla releases the Fiber event loop on every query. While your database is executing a query, your server continues to process other concurrent requests, unlocking massive throughput and concurrency.
- **Familiar, World-Class Developer Experience (DX):** Hibla maps the asynchronous paradigm directly onto the highly beloved, expressive fluent syntax of Laravel's query builder and schema blueprints. If you know Laravel, there is zero learning curve so you write queries the exact same way and simply wrapping your executions in `await()`.
- **Zero-Friction Setup:** Bootstrapping a standalone database in a microframework or custom app is traditionally a tedious process. Hibla provides a single-command initializer (`init`) that auto-scaffolds your configurations, supports instant directory auto-discovery, and utilizes lightweight anonymous classes so you **never have to modify your `composer.json` namespaces** to run migrations or seeders.

---

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

[](#quick-start)

```
composer require hiblaphp/database
```

Add your credentials to a `.env` file:

```
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp
DB_USERNAME=root
DB_PASSWORD=secret
```

Copy the default config to your project root:

```
./vendor/bin/hibla-db init
```

Then run your first query:

```
