Application Doctrine entity table not being created (v8.2.1)

Permalink
I've followed all the instructions on this page -https://documentation.concrete5.org/developers/extending-concrete5-w...

I setup my autoloader in bootstrap/autoload.php like this:

$classLoader = new \Symfony\Component\ClassLoader\Psr4ClassLoader();
$classLoader->addPrefix('Application', DIR_APPLICATION . '/' . DIRNAME_CLASSES);
$classLoader->register();


And then I've added an entity in src/Entity, and set the namespace to Application\Entity.

I've also made sure to do "use Doctrine\ORM\Mapping as ORM;" and prefix all my annotations with "ORM\".

Everything in my app works great, but the database table for my entity is not being created. Does anyone have any idea what I'm doing wrong?

bbeng89
 
mnakalay replied on at Permalink Reply
mnakalay
I think you forgot to mention your Entity folder in your code

$classLoader->addPrefix('Application\\Entity', DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/Entity');
bbeng89 replied on at Permalink Reply
bbeng89
The line I added just maps the entire src/ directory to my Application\ namespace. So that would include Application\Entity. And all the autoloading is working correctly, it just wasn't automatically creating my tables. I just found out about the "Refresh Entities" page on the dashboard though, and I clicked that button and it created the tables. So I'm thinking that's maybe just what you have to do? Maybe tables for entities in /application aren't automatically created like how they are for packages. I dunno.
mnakalay replied on at Permalink Reply
mnakalay
Man, I was going to tell you about that button to refresh entities and my reasoning was exactly that, it's not in a package so you need to install it yourself.

And then I saw that Entity missing and I just stopped thinking...

Anyway, thank you for confirming.
bbeng89 replied on at Permalink Best Answer Reply
bbeng89
Haha, well thanks for your help anyway! Glad I was able to get that figured out.

For anyone else that finds this thread, database tables for Doctrine entities in /application are apparently not automatically created like how they are for packages. So after adding a new entity to your application/src/Entity folder, you need to go to "Dashboard > System & Settings > Environment > Database Entities" and click the red "Refresh Entities" button.