如何解决php应用程序/控制台中的包生成:doctrine:crud [英] How to address the bundle in php app/console generate:doctrine:crud
问题描述
在我的symfony 2项目中,我在
In my symfony 2 project I have a bundle at
src/Cinergy/Bundle/PeopleServiceBundle
现在我想根据一个教义实体生成一个CRUD控制器,但是我一直没有输入正确的字符串对于实体参数。
Now I'd like to generate a CRUD controller based on a doctrine entity, but I'm constantly failing to enter the correct string for the entity parameter.
我尝试过的东西,如:
php app/console generate:doctrine:crud --entity=Cinergy/Bundle/PeopleServiceBundle:Group
或
php app/console generate:doctrine:crud --entity=@PeopleServiceBundle:Group
所有这些都返回错误:
[Doctrine\ORM\ORMException]
Unknown Entity namespace alias '@PeopleServiceBundle'.
- 实体的正确语法是什么?/ code >参数?还是有什么遗失吗?
What's the right syntax for the --entity
parameter? Or is there something missing after all?
目录结构现在如下:
src/Cinergy/Bundle/PeopleServiceBundle/
├── Controller
│ ├── GroupController.php
│ └── PersonController.php
├── DependencyInjection
│ ├── Configuration.php
│ └── PeopleServiceExtension.php
├── PeopleServiceBundle.php
├── Resources
│ ├── config
│ │ ├── routing.yml
│ │ └── services.yml
│ ├── doc
│ │ └── index.rst
│ ├── public
│ │ ├── css
│ │ ├── images
│ │ └── js
│ ├── translations
│ │ └── messages.fr.xliff
│ └── views
│ └── Default
│ └── index.html.twig
└── Tests
└── Controller
├── GroupControllerTest.php
└── PersonControllerTest.php
推荐答案
毕竟,我必须先创建实体,然后才能为其创建CRUD控制器。当然这是有道理的。不幸的是, Sensio Generator Bundle文档按照相反的顺序列出了这些操作,这使我错了方向。
After all it turned out that I have to create the entity before I can create the CRUD controller for it. Of course that makes sense. Unfortunately the Sensio Generator Bundle documentation does list the operations in the oposite order which pushed me into the wrong direction.
这意味着正确的订单ist
This means the correct order ist
- Generating a New Bundle Skeleton
- Generating a New Doctrine Entity Stub
- Generating a CRUD Controller Based on a Doctrine Entity
这篇关于如何解决php应用程序/控制台中的包生成:doctrine:crud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!