0
votes

I have actually finished a project using Symfony2, but my boss want that I change names of tables in the database. He wants to put underscore in the name of my tables, that means underscore in class names.

I tried to do this but it doesn't work. When I do that, I got an error that says: "The entity "entity" cannot be found in "another entity"".

I also try to rename class names without underscore to see if I was doing a mistake but no, that's working.

I search on the web and see maybe a reason who can explain that issue, here it is:

https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md#underscores-in-namespaces-and-class-names

So someone can tell me exactly how can I do to put underscore in my tables names with symfony?

2

2 Answers

1
votes

According to the doc you can separate your table name from your class name.

Just do this :

<?php
/**
 * @Entity
 * @Table(name="my_table_name")
 */
class MyPersistentClass
{
    //...
}

and that's all :)

I have to add that if you re-generate your data model with the app/console doctrine:schema:update --force command you won't destroy existing tables and data. Then you'll have to migrate data by hand from old tables to new ones.

1
votes

There is maybe a better solution: use the underscore naming strategy.

https://stackoverflow.com/a/12702949/244058