Chapter 2. Entities and Mapping Information
In the previous chapter, we discovered the concepts behind Doctrine, we learned how to use Composer to install it, we set up the Doctrine Command Line Tools and we dived into the Entity Manager.
In this chapter, we will cover the following topics:
Creating our first entity class
Mapping it to its related database table and columns with annotations
Using a command helper provided by Doctrine to automatically generate the database schema
Creating some fixtures data and dealing with the Entity Manager to display our data in a web user interface
Because we are building a blog, our main entity class will be called Post
, as shown in the following figure:
Our Post
entity class has the following four properties:
id
: The unique identifier of the post across the database table (and the blog)title
: The post's titlebody
: The post's bodypublicationDate
: The date of publication of the post