The ORM gives you a few layers to work with persisted data:
- entities model stored shape
- repositories handle entity-scoped CRUD work
- the entity manager coordinates broader persistence workflows
- the query builder gives you lower-level SQL-family control when you need it
In Assegai, modules point to a data_source rather than a database. That wording is deliberate. The abstraction is meant to stay broader than one SQL engine or one storage style. Today the first-class family is SQL:
- MySQL
- MariaDB
- PostgreSQL
- SQLite
- MSSQL
Over time, the same top-level idea is meant to grow into additional backends too. That is why these guides talk about entities, data sources, and drivers instead of collapsing everything into database config.
By the end of this track, you should understand:
- what a data source is and why the framework uses that term
- how to configure the ORM in a standalone project or an Assegai app
- how entities map PHP classes to stored records
- how relations model ownership and navigation between entities
- how migrations keep schema changes deliberate and repeatable
- when to use repositories, when to use the entity manager, and when to drop to the query builder
- how driver choice affects configuration and query fluency
- where SQL-specific storage options belong when you need schema, engine, or SQLite
WITHOUT ROWIDbehavior
Read these in order if you are new to the ORM:
- Getting Started
- Data Sources
- Entities
- Relations
- Migrations
- Working with Entity Manager
- Query Builder
- Drivers
There is no single correct starting point for every team.
If you are building an Assegai app, the smoothest route is usually:
assegai add ormassegai database:configure ...assegai database:setup ...- set a module-level
data_source - inject a repository into a service
If you are using the ORM without Assegai, the smoothest route is usually:
composer require assegaiphp/orm- enable only the PDO extension for the driver you want
- configure
OrmRuntime - create a
DataSource - fetch a repository or work through the entity manager
Both are first-class workflows. The difference is mostly where configuration and convenience come from.
If the ORM feels abstract at first, this model usually helps:
- a driver knows how to speak to a specific backend family such as MySQL or PostgreSQL
- a data source is a named configured store that uses one of those drivers
- an entity describes how a PHP class maps to stored data
SqlEntityOptionscarries SQL-only storage choices when you need them- a repository is the everyday entity-scoped API for CRUD-style work
- the entity manager is the broader coordination layer underneath repositories
- the query builder is the lower-level fluent API for SQL-family work when repository options are not enough
- migrations capture schema changes so environments do not drift apart
If you want the fastest route to a working feature, start with Getting Started.
If you already know you need to reason about configuration first, jump straight to Data Sources.