问题
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.
回答1:
Had deleted the AcmeDemoBundle from the project but hadn't removed the related routing code from the routing_dev.yml
file.
回答2:
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
回答3:
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.
回答4:
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.
来源:https://stackoverflow.com/questions/29344078/symfony2-fosuserbundle-error-fileloaderimportcircularreferenceexception