-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
-
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]])composer require initorm/ormComposer 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
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/, …
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.
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 + testThe 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/.
composer update initorm/ormWhen 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.
InitORM ORM · MIT · maintained by Muhammet ŞAFAK · part of the InitORM stack
Getting Started
Models
Entities
Cross-Cutting
Reference
Upgrading
Project