如何解决 php app/console generate:doctrine:crud 中的捆绑包 [英] How to address the bundle in php app/console generate:doctrine:crud

查看:17
本文介绍了如何解决 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

它们都返回错误,例如:

All of them return erros like:

[DoctrineORMORMException]                             
Unknown Entity namespace alias '@PeopleServiceBundle'.

--entity 参数的正确语法是什么?还是毕竟缺少了什么?

What's the right syntax for the --entity parameter? Or is there something missing after all?

这是目录结构现在的样子:

This is how the directory structure looks right now:

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.

这表示顺序正确

  1. 生成新的捆绑包骨架
  2. 生成新的 Doctrine 实体存根
  3. 基于Doctrine实体生成CRUD控制器

这篇关于如何解决 php app/console generate:doctrine:crud 中的捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆