Symfony2 routing error - cannot override class

I am trying to change my routing from annotations in thr routing.yml. Now this is the only configuration in my routing_dev.yml:

user.index: pattern: / defaults: { _controller: AcmeMyBundle:User/UserIndex:index } 

And this is a mistake:

 Fatal error: Cannot redeclare class Acme\MyBundle\Controller\User\UserIndexController in C:\Users\gp\Desktop\xampp\htdocs\project\src\Acme\MyBundle\Controller\User\UserIndexController.php on line 56 

Why is this happening? This is truly the only class with this name. I have no annotations in UserIndexController.

Does anyone have an idea? Thank you very much.

0
source share
2 answers

Try running grep / find in your project for Acme\MyBundle\Controller\User\UserIndexController .

Perhaps you really have a class declared twice.

Then try replacing

 `AcmeMyBundle:User/UserIndex:index` 

with AcmeMyBundle:User\\UserIndex:index

Depending on the version of symfony, it will look for a โ€œnamespace likeโ€ and / or โ€œpath likeโ€.

+5
source

It also happened, it was a file of my controller, I had the wrong namespace .

+1
source

Source: https://habr.com/ru/post/1393651/


All Articles