Doctrine and the database
Part 2 of the Symfony course. The ORM bundle, entities and their columns, migrations, repositories, and OneToMany and ManyToOne relations.
The cards below open the lessons of the part, and the tree lists them in the reading order of the whole
course. The previous and the next page at the bottom move through that order.
2.1
Doctrine setup
Install the ORM bundle, set DATABASE_URL, create the database, and check the connection.
Open
2.2
Entities
Map a table to a PHP class with an entity, columns, generated ids, and a repository.
Open
2.3
Migrations
Turn entities into versioned SQL: make a migration, read it, run it, and roll it back.
Open
2.4
Repositories
How Doctrine repositories fetch entities by id, by criteria, and through small custom methods.
Open
2.5
Relations
How OneToMany and ManyToOne map related entities, with cascade persist and orphan removal notes.
Open