Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Doctrine 2 create ~Entity.php file?

When I generate my entities I have a file prefixed with ~ like a backup file or something

Is it a bug or you need to manually remove them?

like image 968
ÉricP Avatar asked Mar 07 '11 20:03

ÉricP


People also ask

What is a Doctrine entity?

In the Doctrine terminology, a Data Mapper is called an Entity Manager. Entities are plain old PHP objects of the domain layer. Thanks to the Entity Manager, they don't have to be aware that they will be stored in a database.

What is Entity Manager in Doctrine?

The EntityManager is the central access point to ORM functionality. It can be used to find, persist, flush and remove entities.

How does Doctrine work?

Doctrine uses the Identity Map pattern to track objects. Whenever you fetch an object from the database, Doctrine will keep a reference to this object inside its UnitOfWork. The array holding all the entity references is two-levels deep and has the keys root entity name and id.

What is a entity in Symfony?

Well, entity is a type of object that is used to hold data. Each instance of entity holds exactly one row of targeted database table. As for the directories, Symfony2 has some expectations where to find classes - that goes for entities as well.


1 Answers

From the official documentation in Symfony2 CLI command:

$> php app/console help doctrine:generate:entities

....

By default, the unmodified version of each entity is backed up and saved (e.g. Product.php~). To prevent this task from creating the backup file, pass the --no-backup option:

 php app/console doctrine:generate:entities Blog/Entity --no-backup

So to summarize, you may add --no-backup option to your command.

like image 64
Lashae Avatar answered Jan 03 '23 10:01

Lashae