-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
| Requirement | Minimum |
|---|---|
| PHP | 8.1 |
| ext-pdo | Always required |
| ext-pdo_mysql / ext-pdo_pgsql / ext-pdo_sqlite | At least one, matching your target database |
Composer-managed dependencies (installed automatically):
-
initorm/dbal^2.0— PDO connection + DataMapper -
initorm/query-builder^2.0— Fluent SQL builder
composer require initorm/databaseThat's it. No bootstrap step, no service registration, no config files.
Drop this into a script and run it:
<?php
require_once 'vendor/autoload.php';
use InitORM\Database\Database;
$db = new Database([
'driver' => 'sqlite',
'database' => ':memory:',
'charset' => '',
]);
$db->query('CREATE TABLE hello (id INTEGER PRIMARY KEY, msg TEXT)');
$db->create('hello', ['msg' => 'It works!']);
$row = $db->read('hello')->asAssoc()->row();
echo $row['msg'] . PHP_EOL;
// It works!If you see It works!, you're done. Continue with Getting Started.
InitORM speaks any database PDO does. The query builder ships dialect-aware identifier quoting for:
| Driver | Status | Identifier quote |
|---|---|---|
mysql (MySQL / MariaDB) |
First-class |
`column` (backticks) |
pgsql (PostgreSQL) |
First-class |
"column" (double quotes) |
sqlite (SQLite) |
First-class |
`column` (backticks) |
Anything else (oci, sqlsrv, …) |
Generic | No escaping (BYOQ — bring your own quoting) |
For first-class drivers you don't have to think about identifier quoting — the builder picks the right style from the driver credential.
For local development of this package (running tests, lint, static analysis):
composer install # picks up phpunit, phpstan, php_codesniffer
composer qa # cs-ci + stan + testYou don't need any of these in your application; they're behind require-dev.
"composer/installers requires…"
Make sure your project's composer.json doesn't pin an old php constraint. The package requires php: ^8.1.
"could not find package initorm/database"
Check your minimum-stability — the package is on stable, but if your project pins dev you may need prefer-stable: true.
"ext-pdo_mysql is missing"
Install it via your distro's package manager (e.g. sudo apt install php-mysql) or enable the extension in php.ini. The package only requires the generic ext-pdo; specific drivers are listed under suggest.
InitORM Database · MIT · maintained by Muhammet ŞAFAK · part of the InitORM stack
Getting Started
Core Operations
Cross-Cutting
Reference
Upgrading
Project