As I was glancing over a past article I’d written, [Mapping Entities in Symfony2][mapping-entities], I noticed that I had only briefly mentioned the Doctrine
Many of you who use the Symfony console commands to quickly create your Entities will notice that the
@Table(name="") is not included by default on Entities. Just recently I was starting a new application with ~20 Entities to generate. Using the entity generator (seen below) was a huge time-saver, begin by typing the following into terminal.
I primarily develop on a Mac where case sensitivity in MySQL is non-existant. The tablenames in my schema are all lower case, and separated by underscores (ex: user, user_type).
I launched the app on our staging server (running Ubuntu). Immediately the exceptions started popping up:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my_database.User' doesn't exist
It is a minor issue, and luckily very easy to fix!… Declare your table names in your entities!
That’s it, your table-name issues will be solved!