1
I am using Annotations in the project.
In the archive routing.yml
I have the following configuration:
acme_store:
resource: "@AcmeStoreBundle/Controller/"
type: annotation
prefix: /acme
teste_blog:
resource: "@TesteBlogBundle/Controller/"
type: annotation
prefix: /
Notice that in the Bundle AcmeStore
I’m using the prefix acme
.
In the controlling class DefaultController.php
Bundle AcmeStore
, I have the following route configured:
/**
* @Route("/", name="index")
*/
public function indexAction()
{
return $this->render('AcmeStoreBundle:Default:index.html.twig');
}
In the controlling class DefaultController.php
Bundle TesteBlog
, I have the following route configured:
/**
* @Route("/", name="index")
*/
public function indexAction()
{
return $this->render('TesteBlogBundle:Default:index.html.twig');
}
Note that the property name
is equal in the 2 controllers.
On console, when executing command php app/console debug:router
is returned the following result:
------- ------- ------- ----- -----
Name Method Scheme Host Path
------- ------- ------- ----- -----
index ANY ANY ANY /
There shouldn’t be one more line?
------- ------- ------- ----- -----
Name Method Scheme Host Path
------- ------- ------- ----- -----
index ANY ANY ANY /
index ANY ANY ANY /acme
If even using a prefix we can not use the same name
for different routes, what are the best practices when we choose a name for the route?
I ask this because it is possible to install third party Bundles and this can generate conflicts.
Hello Rodrigo, thank you! However I need to give a "name" because I am using Annotations. But using the Bundle name as you posted, already solves problems.
– Filipe Moraes
So, but like I said, you can let the framework generate the names and then see the names in the above command to use them in the application. :)
– Rodrigo Rigotti
Ah ok, got it.
– Filipe Moraes