PHPackages                             webpatser/fledge-fiber-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. webpatser/fledge-fiber-database

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

webpatser/fledge-fiber-database
===============================

Non-blocking Fiber-based database drivers for Fledge/Laravel using amphp

v13.3.0.0(yesterday)05↑500%MITPHPPHP ^8.5

Since Apr 6Pushed yesterdayCompare

[ Source](https://github.com/webpatser/fledge-fiber-database)[ Packagist](https://packagist.org/packages/webpatser/fledge-fiber-database)[ RSS](/packages/webpatser-fledge-fiber-database/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (7)Versions (4)Used By (0)

Fledge Fiber Database
=====================

[](#fledge-fiber-database)

Non-blocking, Fiber-based database drivers for [Fledge](https://github.com/webpatser/fledge) and Laravel 13 using [amphp](https://amphp.org/).

Drop-in replacements for the standard MySQL, MariaDB, and PostgreSQL drivers that suspend PHP Fibers during I/O instead of blocking. This means multiple queries can run concurrently — wall-clock time equals the slowest query, not the sum of all queries.

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

[](#requirements)

- PHP 8.5+
- Fledge / Laravel 13
- `amphp/mysql` ^3.0 (included)
- `amphp/postgres` ^2.0 (optional, for PostgreSQL)

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

[](#installation)

```
composer require webpatser/fledge-fiber-database
```

For PostgreSQL support:

```
composer require amphp/postgres
```

The service provider is auto-discovered — no manual registration needed.

Configuration
-------------

[](#configuration)

Change the `driver` in your `config/database.php`. Everything else stays the same:

```
'connections' => [

    'mysql' => [
        'driver' => 'amphp-mysql',  // was: 'mysql'
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        // Optional pool settings:
        // 'pool_size' => 100,
        // 'pool_idle_timeout' => 60,
    ],

    'pgsql' => [
        'driver' => 'amphp-pgsql',  // was: 'pgsql'
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'schema' => 'public',
        'sslmode' => 'prefer',
    ],

    'mariadb' => [
        'driver' => 'amphp-mariadb',  // was: 'mariadb'
        // ... same config as mysql
    ],

],
```

Available Drivers
-----------------

[](#available-drivers)

DriverPackageDescription`amphp-mysql``amphp/mysql`Non-blocking MySQL via Fibers`amphp-mariadb``amphp/mysql`Non-blocking MariaDB (same wire protocol)`amphp-pgsql``amphp/postgres`Non-blocking PostgreSQL via FibersConcurrent Queries
------------------

[](#concurrent-queries)

Run multiple Eloquent/DB queries in parallel using `FiberDB::concurrent()`:

```
use Fledge\FiberDatabase\FiberDB;

[$users, $posts, $count] = FiberDB::concurrent(
    fn () => User::where('active', true)->get(),
    fn () => Post::latest()->limit(10)->get(),
    fn () => Comment::where('approved', false)->count(),
);
```

All three queries execute in parallel Fibers. Total time equals the slowest query, not the sum.

This works with any database operation — Eloquent models, query builder, raw DB calls:

```
[$a, $b] = FiberDB::concurrent(
    fn () => DB::table('orders')->where('status', 'pending')->get(),
    fn () => DB::select('SELECT count(*) as total FROM invoices WHERE paid = ?', [false]),
);
```

How It Works
------------

[](#how-it-works)

The package provides a thin PDO-compatible shim (`AmphpPdo` / `AmphpPdoStatement`) that wraps amphp's async connection pools. When a query is executed:

1. The current Fiber suspends while waiting for the database response
2. The Revolt event loop progresses other Fibers (other queries, HTTP requests, etc.)
3. When the response arrives, the Fiber resumes with the result

All of this is transparent — Eloquent, Query Builder, migrations, and all existing code works unchanged. The only difference is that I/O no longer blocks.

### Transaction Pinning

[](#transaction-pinning)

Database connection pools dispatch queries to different server connections. This is a problem for transactions (`BEGIN` on connection A, `INSERT` on connection B). The shim handles this automatically — `beginTransaction()` obtains a pinned connection from the pool, and all subsequent queries within that transaction use the same connection until `commit()` or `rollBack()`.

Connection Pooling
------------------

[](#connection-pooling)

amphp manages a connection pool automatically. You can tune it:

```
'mysql' => [
    'driver' => 'amphp-mysql',
    'pool_size' => 100,          // max concurrent connections (default: 100)
    'pool_idle_timeout' => 60,   // seconds before idle connections close (default: 60)
    // ...
],
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Every ~0 days

Total

3

Last Release

1d ago

Major Versions

v0.1.1 → v13.3.0.02026-04-06

### Community

Maintainers

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

---

Top Contributors

[![webpatser](https://avatars.githubusercontent.com/u/25720?v=4)](https://github.com/webpatser "webpatser (4 commits)")

---

Tags

amphpasyncdatabasefiberfledgelaravelmysqlpostgresqlasynclaraveldatabasemysqlpostgresqlamphpfiberfledge

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/webpatser-fledge-fiber-database/health.svg)

```
[![Health](https://phpackages.com/badges/webpatser-fledge-fiber-database/health.svg)](https://phpackages.com/packages/webpatser-fledge-fiber-database)
```

###  Alternatives

[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[moharrum/laravel-adminer

Adminer database management tool for your Laravel application.

451.0k](/packages/moharrum-laravel-adminer)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

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

PHPackages © 2026

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