Generating getters and setters

Doctrine command-line tools that we configured in Chapter 1, Getting Started with Doctrine 2, include a useful command that generates getter and setter methods of an Entity class for us. We will use it to save us from having to write those of the Post class.

Run the following command to generate getters and setters of all entity classes of the application:

  php vendor/bin/doctrine.php orm:generate:entities src/

Note

If you have several entities and don't want to generate getters and setters for all of them, use the filter option with the orm:generate:entities command.

Get Persistence in PHP with Doctrine ORM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.