Symfony2使用实体生成器向导创建和更新字段

I'm trying to create some entities with the symfony2 entity generator wizard:

php app/console doctrine:generate:entity

What I want is to have created_at and updated_at fields on this one entity. I know that symfony2 takes care of those fields, but I wanted to create using the wizard generator. Is it possible? If so, how to I create them? Or do I have to create the entity and then update it through the code to have these fields?

Thanks in advance. CR

By default symfony2 has no automagically created and updated fields

in the generator choose createdAt and datetime you need to set those fields manually.

Or You can use StofDoctrineExtensionsBundle. This describes in symfony cookbook. It contains Timestampable behavior.

/**
 * @var datetime $created
 *
 * @Gedmo\Timestampable(on="create")
 * @ORM\Column(type="datetime")
 */
private $created;

/**
 * @var datetime $updated
 *
 * @Gedmo\Timestampable(on="update")
 * @ORM\Column(type="datetime")
 */
private $updated;

it also makes sense to have an AbstractEntity with those fields as u need them for most entities which can simply extend the AbstractEntity