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

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

alphavel/database
=================

Database package with Query Builder + ORM for Alphavel Framework - #1 Fastest PHP Framework

v1.0.0(5mo ago)052MITPHPPHP &gt;=8.4

Since Nov 26Pushed 5mo agoCompare

[ Source](https://github.com/alphavel/database)[ Packagist](https://packagist.org/packages/alphavel/database)[ RSS](/packages/alphavel-database/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Alphavel Database
=================

[](#alphavel-database)

> High-performance Query Builder + ORM with Laravel-style API

[![PHP Version](https://camo.githubusercontent.com/9c2f8ad80d34105266a94c4c06234f8ed18c968d3595039c2d9a7becd1e71c8b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

---

✨ Features
----------

[](#-features)

- 🚀 **17,000+ req/s** - `findOne()` with global statement cache
- 📈 **+625% faster** - `findMany()` batch queries vs sequential
- 🎯 **Laravel-compatible** - Familiar Query Builder syntax
- ⚡ **Connection pooling** - Coroutine-safe
- 💾 **Global statement cache** - Prepare once, execute millions
- � **Read connection singleton** - Zero coroutine lookup overhead
- 🔒 **Transaction safety** - ACID-compliant isolated connections
- 📚 **ORM (optional)** - Eloquent-like models with relationships

🏆 Performance Benchmarks
------------------------

[](#-performance-benchmarks)

MethodReq/secvs Query BuilderUse Case`DB::findOne()`~17,000**+161%**Single record lookup`DB::findMany()`~8,700**+625%**Batch IN queries`DB::batchFetch()`~10,500**+70%**Different records`DB::table()->get()`~6,500BaselineComplex queries**👉 [See Performance Guide](PERFORMANCE_GUIDE.md) for detailed optimizations**

📦 Installation
--------------

[](#-installation)

```
composer require alphavel/database
```

⚙️ Configuration
----------------

[](#️-configuration)

```
DB_HOST=127.0.0.1
DB_DATABASE=myapp
DB_USERNAME=root
DB_PASSWORD=secret
```

The framework automatically uses optimal settings (no tuning required).

🚀 Quick Start
-------------

[](#-quick-start)

### Hot Path Methods (Maximum Performance)

[](#hot-path-methods-maximum-performance)

```
use Alphavel\Database\DB;

// 1. Single record lookup (17,000+ req/s)
$user = DB::findOne('users', 123);
// SELECT * FROM users WHERE id = ?
// Statement cached globally, zero overhead!

// 2. Batch queries (8,700+ req/s - 625% faster!)
$users = DB::findMany('users', [1, 2, 3, 4, 5]);
// SELECT * FROM users WHERE id IN (1,2,3,4,5)
// Single query instead of 5 queries!

// 3. Multiple different records (10,500+ req/s)
[$user, $product, $order] = DB::batchFetch('entities', [$userId, $productId, $orderId]);
// Reuses same cached statement 3 times
```

### Query Builder (Complex Queries)

[](#query-builder-complex-queries)

```
// Use when you need filters, joins, pagination
$users = DB::table('users')
    ->where('status', 'active')
    ->where('age', '>', 18)
    ->orderBy('created_at', 'DESC')
    ->limit(10)
    ->get();

// Insert
DB::table('users')->insert([
    'name' => 'John Doe',
    'email' => 'john@example.com',
]);

// Transactions
DB::transaction(function() {
    DB::execute('INSERT INTO orders ...');
    DB::execute('INSERT INTO order_items ...');
});
```

### Models (ORM)

[](#models-orm)

```
use App\Models\User;

// Find
$user = User::find(1);
$users = User::where('active', true)->get();

// Create
$user = User::create([
    'name' => 'Jane Doe',
    'email' => 'jane@example.com',
]);

// Update
$user->name = 'John Smith';
$user->save();

// Relationships
$posts = $user->posts;  // Lazy loading
$users = User::with('posts')->get();  // Eager loading
```

📚 Documentation
---------------

[](#-documentation)

**Full documentation**:

- [Query Builder](https://github.com/alphavel/documentation/blob/master/packages/database/query-builder.md)
- [ORM (Models)](https://github.com/alphavel/documentation/blob/master/packages/database/orm.md)
- [Migrations](https://github.com/alphavel/documentation/blob/master/packages/database/migrations.md)
- [Performance](https://github.com/alphavel/documentation/blob/master/packages/database/performance.md)
- [Best Practices](https://github.com/alphavel/documentation/blob/master/packages/database/best-practices.md)

📄 License
---------

[](#-license)

MIT License

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance70

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

173d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51c953df141d0cfd39946d3e417b2eb3106d96170c62c4c908a6cc0b75352883?d=identicon)[arthur4weber](/maintainers/arthur4weber)

---

Top Contributors

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

---

Tags

databaseperformanceormpdoeloquentswoolequery builderlaravel-stylealphavel

### Embed Badge

![Health badge](/badges/alphavel-database/health.svg)

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

###  Alternatives

[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.

845.7k](/packages/tommyknocker-pdo-database-class)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3516.7k3](/packages/wayofdev-laravel-cycle-orm-adapter)[andreagroferreira/laravel-sync-tracker

A Laravel package for tracking entity synchronization status between systems

113.0k](/packages/andreagroferreira-laravel-sync-tracker)

PHPackages © 2026

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