Skip to content

Installation

Muhammet Şafak edited this page May 24, 2026 · 1 revision

Installation

Requirements

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):

Install

composer require initorm/database

That's it. No bootstrap step, no service registration, no config files.

Verify

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.

Picking a driver

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.

Optional dev dependencies

For local development of this package (running tests, lint, static analysis):

composer install   # picks up phpunit, phpstan, php_codesniffer
composer qa        # cs-ci + stan + test

You don't need any of these in your application; they're behind require-dev.

Troubleshooting installation

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

Clone this wiki locally