PHPackages                             assegaiphp/orm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. assegaiphp/orm

ActiveLibrary[Database &amp; ORM](/categories/database)

assegaiphp/orm
==============

AssegaiORM is a standalone ORM for modern PHP applications, with optional AssegaiPHP integration.

0.9.1(1mo ago)0295MITPHPPHP &gt;=8.4CI passing

Since Aug 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/assegaiphp/orm)[ Packagist](https://packagist.org/packages/assegaiphp/orm)[ RSS](/packages/assegaiphp-orm/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (17)Versions (85)Used By (0)

 [![Assegai Logo](https://camo.githubusercontent.com/d7dab2658d76e460e31be249de2fe5d420f7a7237eb9f2a315f83123632a3b6c/68747470733a2f2f617373656761697068702e636f6d2f696d616765732f6c6f676f732f6c6f676f2d63726f707065642e706e67)](https://assegaiphp.com/)

 [![Latest release](https://camo.githubusercontent.com/cc194e01651734928383ddffa5cbbabd688b6972aa7cc635299d1eb1656d5d19/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f617373656761697068702f6f726d3f646973706c61795f6e616d653d74616726736f72743d73656d766572267374796c653d666c61742d737175617265)](https://github.com/assegaiphp/orm/releases) [![Tests](https://camo.githubusercontent.com/11c8722bd07437777b0f392ae3aea81760a71ce6a407e1a25a8285b64da1f4c9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f617373656761697068702f6f726d2f7068702e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/assegaiphp/orm/actions/workflows/php.yml) [![PHP 8.4+](https://camo.githubusercontent.com/51482859d8bb7cd31d259f58cf02b8eb7e56c51ad36c462afa3484f3b7a8fc2c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/51482859d8bb7cd31d259f58cf02b8eb7e56c51ad36c462afa3484f3b7a8fc2c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465) [![License](https://camo.githubusercontent.com/af3215187dc98351de17dd4faa42daaae447310a2ddaf5daabb1d962884468f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f617373656761697068702f6f726d3f7374796c653d666c61742d737175617265)](https://github.com/assegaiphp/orm/blob/main/LICENSE) [![Status active](https://camo.githubusercontent.com/1214b36790042a591c22d285a8cbfdc3c33d1cbbbed099a0bca2f5edd79ca2a0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d3130623938313f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/1214b36790042a591c22d285a8cbfdc3c33d1cbbbed099a0bca2f5edd79ca2a0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d3130623938313f7374796c653d666c61742d737175617265)

A standalone ORM for modern PHP applications, with optional AssegaiPHP integration.

Description
-----------

[](#description)

An object-relational mapper for modern PHP applications. You can use it on its own, or plug it into [AssegaiPHP](https://github.com/assegaiphp) when you want repository injection and framework conventions.

Contribution workflow
---------------------

[](#contribution-workflow)

For commit and pull request conventions in this repo, see:

- [docs/commit-and-pr-guidelines.md](./docs/commit-and-pr-guidelines.md)

Installation
------------

[](#installation)

```
$ assegai add orm
```

That is the preferred path inside an Assegai workspace. It will:

- require `assegaiphp/orm` if it is missing
- import `OrmModule` into the root module
- make the ORM CLI commands available through package discovery

If you install the package manually first, `assegai add orm` is still safe to run afterward. It will just finish the workspace wiring.

For standalone PHP projects that are not using Assegai, install the package directly:

```
$ composer require assegaiphp/orm
```

Then enable only the PDO driver you actually plan to use:

- `pdo_mysql` for MySQL or MariaDB
- `pdo_pgsql` for PostgreSQL
- `pdo_sqlite` for SQLite

AssegaiORM no longer forces all three database extensions at install time. If you choose a driver without enabling its matching PDO extension, the ORM will tell you exactly which extension is missing when you try to connect.

Guide map
---------

[](#guide-map)

This package is designed to feel familiar to teams coming from TypeORM:

- entities describe persistence shape
- repositories can be used directly or injected into services in Assegai
- data sources decide where a feature reads and writes
- relations are explicit and ownership matters
- migrations evolve the schema deliberately

In the main Assegai guide set, the ORM track is:

- `core/docs/data-and-orm.md`
- `core/docs/orm-setup-and-data-sources.md`
- `core/docs/orm-entities-repositories-and-results.md`
- `core/docs/orm-relations.md`
- `core/docs/orm-migrations-and-database-workflows.md`

Quick Start
-----------

[](#quick-start)

[Overview &amp; Tutorial](https://assegaiphp.com/guide/fundamentals/orm)

Using it without Assegai
------------------------

[](#using-it-without-assegai)

You can use AssegaiORM directly in any PHP project. The standalone path is:

1. configure named databases for the ORM runtime
2. create a `DataSource`
3. create or fetch repositories from that data source

```
