Symfony 2 and Doctrine
If y0u have a database, probably you need to generate entities automatically. We'll use the console on app\console. But there are other small tricks you have to know. Let's see some very useful commands:
Using basic Doctrine commands you can have an error about enum types. It's highly recommended to add enum strings. Take a look at the official enum reference page on doctrine website. The second answer on this page on stackoverflow will definitely solve our problem. Check out this section on official symfony website.
Generate entities from existing database
php app/console doctrine:mapping:import --force AcmeApplicationBundle xml
Generate setters and getters:
php app/console doctrine:generate:entities AcmeApplicationBundle
Remember to replace AcmeApplicationBundle with the name of the Bundle where you want to generate the files. The link on the official website is this one. I usually delete the old entities on /src/Acme/AcmeApplicationBundle/Entity/ and XMLfiles on /src/Acme/AcmeApplicationBundle/Resources/config/doctrine/ Generate single entity If you want to generate a single entity file use the following command:
php app/console doctrine:generate:entity
The script will ask you the entity name.