Skip to content

Installation

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

Installation

Requirements

  • PHP 8.1 or later — the package uses readonly properties, match expressions, and enum-adjacent features that landed in 8.1.
  • ext-pdo — the connection layer is pure PDO.
  • One PDO driver extension, depending on the database you target:
Driver PHP extension
MySQL / MariaDB ext-pdo_mysql
PostgreSQL ext-pdo_pgsql
SQLite ext-pdo_sqlite
Anything else the matching ext-pdo_*

Verify on the command line:

php -m | grep -i pdo
# pdo
# pdo_mysql        (or whichever driver you need)
# pdo_sqlite       (recommended for the test suite — see [[Testing]])

Install via Composer

composer require initorm/orm

Composer pulls in the rest of the InitORM stack transitively — you do not need to add initorm/database, initorm/dbal, or initorm/query-builder yourself:

initorm/orm  ──►  initorm/database  ──►  initorm/dbal
                                    └►   initorm/query-builder

What gets installed

After composer install:

vendor/
├── initorm/
│   ├── orm/             ← models + entities (this package)
│   ├── database/        ← CRUD + transactions + facade
│   ├── dbal/            ← PDO Connection + DataMapper
│   └── query-builder/   ← fluent SQL string assembly
└── composer/, …

Verify the install

A two-line smoke test against in-memory SQLite — no schema, no credentials:

<?php
require __DIR__ . '/vendor/autoload.php';

use InitORM\Database\Facade\DB;

DB::createImmutable([
    'driver'   => 'sqlite',
    'database' => ':memory:',
    'charset'  => '',
]);

DB::getPDO()->exec('CREATE TABLE t (id INTEGER PRIMARY KEY, name TEXT)');

class T extends \InitORM\ORM\Model
{
    protected string $schema = 't';
}

(new T())->create(['name' => 'Hello']);
foreach ((new T())->read()->rows() as $row) {
    echo $row->name, PHP_EOL;  // Hello
}

If that prints Hello, your install is good. Move on to Getting Started.

Development install

If you intend to hack on the package itself:

git clone https://github.com/InitORM/ORM.git
cd ORM
composer install      # pulls in PHPUnit, PHP_CodeSniffer, PHPStan
composer qa           # cs + stan + test

The dev dependencies are pinned at versions known to work with PHP 8.1–8.4 and are mirrored by the CI workflows in .github/workflows/.

Updating

composer update initorm/orm

When you cross a major version boundary, read Migration from v1 to v2 first — v2 changed Helper output, Entity accessor signatures, and a couple of permission-flag semantics.

Clone this wiki locally