Reputation: 166166
Symfony: Problems Importing the bundle routing resource
I'm trying to use the Symfony app console to generate a bundle,
$ php app/console generate:bundle
but I keep getting the error
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.
Does anyone know how to solve this? In other words, what are common causes of this error, and what, specifically is the app console doing when it performs an automatic update of the Routing. Lacking that, is there an ideal place to jump into the source code to start debug-hacking on why this is failing?
Context: I'm an experienced programmer, but newish to Symfony development. I had generated a new bundle to follow along with a tutorial. However, I realized I accidentally created a bundle using the annotation format instead of the yaml/yml format. Not being sure of the differentce, I wanted to regenerate the bundle. To do this
I removed the bundle declaration from the AppKernel
I re-generated the app/bootstrap.php.cache
file using the build_bootstrap.php
script
I removed the source code of my bundle from the src
folder where it was generated (this folder is otherwise empty)
However, whenever I run through the generate:bundle
command steps, it always ends with
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.
So, my assumption is there's some artificat in my codebase from the previous generation attempt that's causing this error, but I don't have enough Symfonyt experience to track this down.
I've included the entire CLI interaction below in case it helps with troubleshooting.
$ 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.
Upvotes: 0
Views: 5135
Reputation: 166166
As I suspected, the problem was between the screen and the keyboard. While each bundle in Symfony may have its own routing.yml
file, there's a master file at
app/config/routing.yml
This file points at each individual bundle's routing file. When you "Importing the bundle routing resource", you're adding a configuration entry to this file.
#app/config/routing.yml
pulsestorm_helloworld:
resource: "@PulsestormHelloworldBundle/Resources/config/routing.yml"
prefix: /
Because I didn't know about this app/config/routing.yml
file, I failed to remove the configuration that had been previously added. That's what the console application had been complaining about. When I remove the above from the master routing.yml file, I could get a a clean run of the Bundle generation.
Upvotes: 3