Tom
Tom

Reputation: 268

Symfony2 FOSUserBundle error - FileLoaderImportCircularReferenceException

I'm trying to install FOSUserBundle on a new symfony2 project. I've followed the steps to get it installed but I'm still having trouble with this error:

FileLoaderImportCircularReferenceException in FileLoader.php line 97:
Circular reference detected in "/Users/tom/Sites/symfony/todo/app/config/routing_dev.yml" ("/Users/tom/Sites/symfony/todo/app/config/routing_dev.yml" > "/Users/tom/Sites/symfony/todo/app/config/routing.yml" > "/Users/tom/Sites/symfony/todo/app/config/routing_dev.yml").

When I try to run php app/console router:debug I am getting the error:

 [Symfony\Component\Config\Exception\FileLoaderLoadException]                                              
  Cannot load resource "@FOSUserBundle/Resources/config/routing/all.xml". Make sure the "FOSUserBundle" bu  
  ndle is correctly registered and loaded in the application kernel class.     

Even though I am loading the bundle in the AppKernel.

In routing.yml I have (if it helps):

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

Can't seem to find anything on this however I apologise if I haven't searched around well enough.

Upvotes: 4

Views: 2712

Answers (4)

Sebastiaan Ordelman
Sebastiaan Ordelman

Reputation: 942

I had the same problem and error message, but I could not find any circular reference.

The problem: indentation in the yml file.

abc_bundle_route:
path:     /my-url/{id}
defaults: { _controller: ABCBundle:Monitor:mycontroller, id: 0 }
    requirements:
        id: -?\d+

Is not the same as the (correct):

abc_bundle_route:
path:     /my-url/{id}
defaults: { _controller: ABCBundle:Monitor:mycontroller, id: 0 }
requirements:
    id: -?\d+

By setting the correct indentation, the error was solved.

Upvotes: 0

Michael Butler
Michael Butler

Reputation: 6309

This will also happen if you delete the line:

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

from your Controller. Symfony needs this line for the @Route annotation.

Upvotes: 0

otrojuliom
otrojuliom

Reputation: 1

If cache does not work for you, look if you are include the required namespaces for use annotations routes in your controller, in my case i was missing to add:

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

in my controller. I open an issue because the exception throw is wrong for this case, since it says the same error:

FileLoaderImportCircularReferenceException

Upvotes: 0

Tom
Tom

Reputation: 268

Had deleted the AcmeDemoBundle from the project but hadn't removed the related routing code from the routing_dev.yml file.

Upvotes: 3

Related Questions