raxos / database
Database ORM and Query Builder.
Requires
- php: >=8.5
- ext-pdo: *
- jetbrains/phpstorm-attributes: ^1.2
- raxos/collection: *
- raxos/contract: *
- raxos/error: *
- raxos/foundation: *
Requires (Dev)
- pestphp/pest: ^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 3.2.0
- 3.1.0
- 3.0.1
- 3.0.0
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-copilot/improve-orm-functionality
- dev-copilot/improve-query-builder-functionality
- dev-copilot/fix-push-main-branch-issue
- dev-copilot/fix-978257-317799358-bd6009d6-7e31-4343-9a08-d8246bad2507
- dev-copilot/update-expressions-to-handle-subqueries
- dev-copilot/improve-query-builder-validation
- dev-copilot/improve-case-when-expressions
- dev-copilot/improve-eager-loading-in-orm
- dev-copilot/optimize-through-relations-orm
- dev-feature/SqlServer
This package is auto-updated.
Last update: 2026-10-03 12:49:52 UTC
README
Raxos Database
A PDO query builder and an ORM configured with PHP attributes for SQLite, MySQL and MariaDB.
Documentation | Packagist | Raxos
- Prepared queries, expressions, transactions and query logging.
- Models with casts, views, soft deletes, computed values and relationship attributes.
- Eager loading, SQL counts, pagination and batched model cursors.
Installation
Requires PHP 8.5 or later. Enable the pdo PHP extension. Composer checks the remaining package and extension dependencies declared in composer.json.
composer require "raxos/database:^3.2"
Usage
<?php declare(strict_types=1); use Raxos\Database\Connection\SQLite; use Raxos\Database\Db; use Raxos\Database\Orm\Attribute\Column; use Raxos\Database\Orm\Attribute\PrimaryKey; use Raxos\Database\Orm\Attribute\Table; use Raxos\Database\Orm\Model; require __DIR__ . '/vendor/autoload.php'; #[Table('products')] final class Product extends Model { #[PrimaryKey] public int $id; #[Column] public string $name; } Db::register(SQLite::createFromInMemory()); Db::execute('CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT NOT NULL)'); Db::query()->insertIntoValues('products', ['id' => 42, 'name' => 'Keyboard'])->run(); foreach (Product::select()->orderBy('id')->cursor(batchSize: 100) as $product) { echo $product->name . PHP_EOL; }
Enable pdo_sqlite for this example. Use Connection\MySql or Connection\MariaDb with a matching PDO driver for those servers.
Model cursors hydrate 100 items per batch by default and release identities introduced by each batch. Pass retainCache: true when those identities must remain available afterward. Previously cached models are retained.
Documentation
Testing
Run this library's Pest suite from the Raxos workspace:
git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=database
See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.
License
MIT. Copyright (c) 2017 - present Bas Milius.