Symfony:导入捆绑路由资源的问题
我正在尝试使用Symfony app控制台生成一个包,
$ php app/console generate:bundle
但我一直收到错误
Confirm automatic update of the Routing [yes]?
Importing the bundle routing resource: FAILED
The command was not able to configure everything automatically.
You must do the following changes manually.
Bundle PulsestormHelloworldBundle is already imported.
有谁知道如何解决这个问题?换句话说,这个错误的常见原因是什么,具体是应用程序控制台执行自动更新路由时所做的事情。缺乏这个,是否有一个理想的地方跳进源代码开始调试黑客为什么这是失败?
背景:我是一名经验丰富的程序员,但对Symfony开发很新。我已经生成了一个新的包以跟随教程。但是,我意识到我不小心使用注释格式而不是yaml / yml格式创建了一个包。不确定不同,我想重新生成捆绑。要做到这一点
我从AppKernel
我使用app/bootstrap.php.cache
脚本重新生成了build_bootstrap.php
文件
我从生成它的src
文件夹中删除了我的包的源代码(此文件夹为空)
但是,每当我执行generate:bundle
命令步骤时,它始终以
Confirm automatic update of the Routing [yes]?
Importing the bundle routing resource: FAILED
The command was not able to configure everything automatically.
You must do the following changes manually.
Bundle PulsestormHelloworldBundle is already imported.
所以,我的假设是我的代码库中存在一些导致此错误的上一代尝试的技巧,但我没有足够的Symfonyt经验来跟踪它。
我已经在下面包含了整个CLI交互,以防它有助于排除故障。
$ php app/console generate:bundle
Welcome to the Symfony2 bundle generator
Your application code must be written in bundles. This command helps
you generate them easily.
Each bundle is hosted under a namespace (like Acme/Bundle/BlogBundle).
The namespace should begin with a "vendor" name like your company name, your
project name, or your client name, followed by one or more optional category
sub-namespaces, and it should end with the bundle name itself
(which must have Bundle as a suffix).
See http://symfony.com/doc/current/cookbook/bundles/best_practices.html#index-1 for more
details on bundle naming conventions.
Use / instead of \ for the namespace delimiter to avoid any problem.
Bundle namespace: Pulsestorm/Bundle/HelloworldBundle
In your code, a bundle is often referenced by its name. It can be the
concatenation of all namespace parts but it's really up to you to come
up with a unique name (a good practice is to start with the vendor name).
Based on the namespace, we suggest PulsestormHelloworldBundle.
Bundle name [PulsestormHelloworldBundle]:
The bundle can be generated anywhere. The suggested default directory uses
the standard conventions.
Target directory [/Users/alanstorm/Documents/github_oro/crm-application/src]:
Determine the format to use for the generated configuration.
Configuration format (yml, xml, php, or annotation) [annotation]: yml
To help you get started faster, the command can generate some
code snippets for you.
Do you want to generate the whole directory structure [no]? yes
Summary before generation
You are going to generate a "Pulsestorm\Bundle\HelloworldBundle\PulsestormHelloworldBundle" bundle
in "/Users/alanstorm/Documents/github_oro/crm-application/src/" using the "yml" format.
Do you confirm generation [yes]?
Bundle generation
Generating the bundle code: OK
Checking that the bundle is autoloaded: OK
Confirm automatic update of your Kernel [yes]?
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]?
Importing the bundle routing resource: FAILED
The command was not able to configure everything automatically.
You must do the following changes manually.
Bundle PulsestormHelloworldBundle is already imported.
答案 0 :(得分:3)
我怀疑,问题出在屏幕和键盘之间。虽然Symfony中的每个包都可能有自己的routing.yml
文件,但是
app/config/routing.yml
此文件指向每个捆绑包的路由文件。当您“导入捆绑包路由资源”时,您将向此文件添加配置条目。
#app/config/routing.yml
pulsestorm_helloworld:
resource: "@PulsestormHelloworldBundle/Resources/config/routing.yml"
prefix: /
因为我不知道这个app/config/routing.yml
文件,所以我无法删除之前添加的配置。这就是控制台应用程序一直在抱怨的内容。当我从master routing.yml文件中删除上面的内容时,我可以得到一个干净的Bundle生成。
答案 1 :(得分:1)
删除捆绑listed in this article的所有部分的步骤和提示。也许这很有用。