1
0
Fork
You've already forked quma
0
A no-ORM database library for executing raw SQL files
  • PHP 100%
Thomas Ernst bc7ab4a31f
All checks were successful
ci / ci (push) Successful in 2m28s
Allow manual CI runs
2026年06月10日 20:58:19 +02:00
.forgejo/workflows Allow manual CI runs 2026年06月10日 20:58:19 +02:00
.github Update readme 2026年05月29日 16:35:32 +02:00
docs Update composer scripts 2026年05月28日 18:29:30 +02:00
src Rename hydration failure exceptions 2026年05月26日 20:54:43 +02:00
tests Rename hydration failure exceptions 2026年05月26日 20:54:43 +02:00
.editorconfig Sync shared config files 2026年01月30日 22:06:10 +01:00
.gitattributes Update .gitattributes 2026年04月26日 12:43:03 +02:00
.gitignore Update .gitignore 2026年04月26日 17:51:06 +02:00
CHANGELOG.md Rename hydration failure exceptions 2026年05月26日 20:54:43 +02:00
composer.json Update composer scripts 2026年05月28日 18:29:30 +02:00
LICENSE.md Update license 2026年05月12日 20:25:39 +02:00
mago.toml Domain type mapping ( #8 ) 2026年04月29日 08:08:21 +02:00
phpunit.xml.dist Update coverage config 2026年05月12日 19:55:35 +02:00
psalm.xml.dist Add request-scoped query debug logging ( #10 ) 2026年05月02日 18:27:45 +02:00
README.md Update readme 2026年05月29日 16:35:32 +02:00

Celemas Quma

ci code coverage type coverage psalm level Software License

Quma is a no-ORM database library for PHP. You store SQL in files, group those files in folders, and execute them through a small PDO-backed API. Quma also ships with template queries and a migration runner.

Requirements

Quma currently requires:

  • PHP 8.5 or newer
  • ext-json
  • ext-pdo
  • ext-readline

Install

composer require celemas/quma

Quickstart

Create a SQL directory structure like this:

sql/
 users/
 byId.sql
 list.sql

Add a query file:

SELECTid,emailFROMusersWHEREid=?;

Then configure Quma and run the query:

<?php
declare(strict_types=1);
use Celemas\Quma\Connection;
use Celemas\Quma\Database;
$conn = new Connection(
 'sqlite:' . __DIR__ . '/app.sqlite',
 __DIR__ . '/sql',
)->migrations(__DIR__ . '/migrations');
$db = new Database($conn);
$user = $db->users->byId(1)->one();
$users = $db->users->list()->all();

Quma maps directories to properties and files to methods:

  • sql/users/byId.sql becomes $db->users->byId()
  • sql/users/list.sql becomes $db->users->list()

What Quma provides

  • SQL-file based queries with positional or named parameters
  • explicit static /*:name:*/ placeholders for trusted driver-aware configuration fragments
  • PDO-backed execution with exact one(), stable first(), cursor-style fetch(), all(), lazy(), run(), and len()
  • optional row hydration into typed objects
  • PHP-powered SQL templates via .tpql files
  • multiple SQL directories with driver-specific overrides
  • migration commands for .sql, .tpql, and .php migrations
  • environment-controlled debug output for translated and interpolated SQL

Documentation

Start with the docs in docs/index.md.

Recommended pages:

Testing

Quma runs against SQLite by default and can also run against MySQL and PostgreSQL when you provide test databases.

composer test
composer test:sqlite
composer test:mysql
composer test:pgsql
composer test:all

For database setup and environment variables, see docs/testing.md.

License

This project is licensed under the MIT license.