alphavel/database
Composer 安装命令:
composer require alphavel/database
包简介
Database package with Query Builder + ORM for Alphavel Framework - #1 Fastest PHP Framework
README 文档
README
High-performance Query Builder + ORM with Laravel-style API
✨ 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
| Method | Req/sec | vs Query Builder | Use 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,500 | Baseline | Complex queries |
👉 See Performance Guide for detailed optimizations
📦 Installation
composer require alphavel/database
⚙️ 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
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)
// 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)
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
Full documentation: https://github.com/alphavel/documentation
📄 License
MIT License
alphavel/database 适用场景与选型建议
alphavel/database 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「orm」 「performance」 「pdo」 「eloquent」 「query-builder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alphavel/database 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alphavel/database 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alphavel/database 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
g4 application profiler package
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
WordPress mu-plugin to remove jQuery Migrate from the list of jQuery dependencies and to allow jQuery to enqueue before </body> instead of in the <head>.
Kinikit - PHP Application development framework MVC component
Store your language lines in the database, yaml or other sources
统计信息
- 总下载量: 52
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-19