I am testing the new Symfony 4 schema with Flex and I'm having a big trouble while creating a Doctrine Entity or creating the Entity Entities.
In previous versions of Symfony, you can create the entities with the command:
php bin/console doctrine:generate:entities
and
php bin/console doctrine:generate:entities App:MyBundle:MyEntity
In this version (Symfony 3.3-dev with the new Flex skeleton) the new folder structure "removes" the old Bundle structure, and when executing the above commands to create an Entity in ./src/Entity
it returns and error like this:
[RuntimeException] Can't find base path for "App\Entity\ExampleEntity" (path: "/mnt/c/.../src/Entity", destination: "/mnt/c/.../src/Entity").
The question is, that is any way to generate an Entity, or the Entity Entities focusing to a path and not with the PSR-4 autoload directive.
Thanks in advance!!!
Not a fix by any means but a workaround till they catch up. Very much a cowboy method.
php bin/console doctrine:generate:entities AppBundle
Sorry, it's far from ideal, but the easiest method I've found rather than having to generate all the getter/setters by hand.
UPDATE: 25/01/2017
As of 4.x the whole idea of
doctrine:generate:entities
has been dropped (In this issue after a long read you'll notice that Doctrine has dropped the commands completely, hence the new Symfony maker bundle).Apparently, it's viewed as bad practice. Instead, they've released a new package called maker, which essentially creates the entity class for you but without the getters/setters, and the new suggested practice is to rely on your IDE to auto-generate the Getters and Setters for you.
This works except for the constructor for
ArrayCollections
for@OneToMany
, but it doesn't take much to add these by hand.What I've said above is also reflected in the Symfony documentation.