minychillo
minychillo

Reputation: 515

Doctrine create setters and getters?

OK, I am missing something here ... I want to start using Doctrine 2. Now I created an entity class "recepie" with annotations:

/**
* @Entity
*/

class recepie 
{

  /**
  * @Id @Column(type="integer")
  * @GeneratedValue
  */
  private $id;

  /** @Column(length=500) */
  private $titleDE;

  /** @Column(length=4000) */
  private $descDE;

  /** @Column(length=4000) */
  private $instructDE;

  /** @Column(type="date") */
  private $postedAt;

  /** @Column(type="integer") */
  private $skill;

  /** @Column(type="integer") */
  private $prepTime;

  /** @Column(type="smallint") */
  private $personNum;

  /** @Column(type="boolean") */
  private $isPublic;


}

Now I try to auto generate setters and getters using:

php vendor/bin/doctrine orm:generate-entities entities/

Now this creates a new file called "recipie.php~", probably not to overwrite the existing recipie.php file that contains the initial entity.

What is the idea here ? Am I supposed to open that file and copy/paste the getters and setters into my initial entity class ? What am I missing ?

Upvotes: 0

Views: 982

Answers (1)

Don't Panic
Don't Panic

Reputation: 41810

Your idea is on the right track, but not quite right. Actually generate-entities does modify your existing entity file, and those files with ~ appended to their names are just backup files that generate-entities creates beforehand.

The accessor methods should be created in the original file. If everything looks okay, you can delete the backup file. You shouldn't have to copy and paste anything from it. If you want to run generate-entities without creating those files, you can use the --no-backup option.

Upvotes: 2

Related Questions