Symfony3 : Generate crud doesn't work

2019-07-03 10:05发布

问题:

I'm trying to use the generate crud feature with my new symfony3 project. I have created a bundle named AdminBundle with the generator, the entity test, also with the generator, all processed well to the end. I checked my file under, i have my class Test.php generated under my src/AdminBundle/Entity/Test.php folder. All is working well.

But when i try to generate a crud following the doc for my test entity with the following command :

bin/console generate:doctrine:crud
The Entity shortcut name: AdminBundle:Test

I get the following error :

[RuntimeException] Entity "Test" does not exist in the "AdminBundle" bundle. You may have mistyped the bundle name or maybe the entity doesn't exist yet (create it first with the "doctrine:generate:entity" comm and).

As i said, i already generated the entity with the "doctrine:generate:entity" command, and i type the same name ( AdminBundle:Test ) as i type in my crud generator.

Any ideas ?

回答1:

I have the same problem with sf2.8.

What I did to solve this problem was:

first: generate the form for the entity. php app/console doctrine:generate:form NameBundle:EntityName

Second: generate the CRUD for Entity php app/console doctrine:generate:crud



回答2:

I just ran into this problem. One of my entity's attributes annotations were mistyped, causing this error. Check your attributes annotations.



回答3:

I had to do bin/console doctrine:schema:update for it to acknowledge the entity as I had the class but the entity was not in the DB yet.



回答4:

It's an old issue. But I face it too, just now. I solved it by pointing the class with whole name space.

$test = new \AppBundle\Entity\Test();