I am trying to use doctrine to generate entities in symfony 4 from mysql database.
Firstly, I created a bundle called AppBundle.php in a directory called AppBundle
I then generate the xml of the schema using:
php bin/console doctrine:mapping:import --force AppBundle xml
This will create a folder called Resources in the AppBundle folder and then another folder called config and doctrine and all the orm.xml files are put in there.
Then I try to generate the entities using:
php bin/console doctrine:mapping:convert annotation ./src/Entity
This creates the following folders in the Entity folder:
- Entity
- App
- AppBundle
- Entity
And all the .php entity files are put in the second Entity folder.
The .php entity files have the following namespace
namespace App\AppBundle\Entity;
In my controller I added the name space
use App\AppBundle\Entity\User;
and use doctrine to fetch
$users = $this->getDoctrine()
->getRepository(User::class)
->findAll();
but when I run the application I get this error
Now, when I move the second Entity folder into the AppBundle folder. The application works.
Is there a way to generate entities without Symfony generating the App folder or the AppBundle folder?