在 routing_dev.yml 中检测到循环引用

Posted

技术标签:

【中文标题】在 routing_dev.yml 中检测到循环引用【英文标题】:Circular reference detected in routing_dev.yml 【发布时间】:2015-07-14 10:17:46 【问题描述】:

我对这个 循环参考 问题感到疯狂,我找不到我做错了什么。这是/app/config/routing.yml的内容:

pd_one:
    resource: "@PDOneBundle/Controller/"
    type:     annotation
    prefix:   /

template:
    resource: "@TemplateBundle/Controller/"
    type:     annotation
    prefix:   /

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

restful_services:
    resource: "@PDOneBundle/Resources/config/routing.yml"
    type:     rest
    prefix:   /api

nelmio_apidoc:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /api/doc

admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /admin

_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin

这是/app/config/routing_dev.yml的内容:

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_configurator:
    resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
    prefix:   /_configurator

_errors:
    resource: "@TwigBundle/Resources/config/routing/errors.xml"
    prefix:   /_error

_main:
    resource: routing.yml

最后这是/src/PDI/PDOneBundle/Resources/config/routing.yml的内容:

service_company:
    type: rest
    prefix: /v1
    resource: PDOneBundle\Controller\CompanyRestController
    name_prefix:  api_1_ # naming collision

每当我在dev env 尝试一些 URL 时,我都会收到此错误:

classes.php 第 7527 行中的 FileLoaderImportCircularReferenceException: 检测到圆形参考 “/var/www/html/reptooln_admin/app/config/routing_dev.yml” ("/var/www/html/reptooln_admin/app/config/routing_dev.yml" > “/var/www/html/reptooln_admin/app/config/routing.yml” > "/var/www/html/reptooln_admin/src/PDI/PDOneBundle/Resources/config/routing.yml"

"/var/www/html/reptooln_admin/app/config/routing_dev.yml")。

这是完整的堆栈跟踪|日志:

in classes.php line 7527
at FileLoader->import('/var/www/html/reptooln_admin/app/config/routing_dev.yml', null, false, '/var/www/html/reptooln_admin/app/cache/dev/assetic/routing.yml') in YamlFileLoader.php line 155
at YamlFileLoader->parseImport(object(RouteCollection), array('resource' => '/var/www/html/reptooln_admin/app/config/routing_dev.yml'), '/var/www/html/reptooln_admin/app/cache/dev/assetic/routing.yml', '/var/www/html/reptooln_admin/app/cache/dev/assetic/routing.yml') in YamlFileLoader.php line 91
at YamlFileLoader->load('/var/www/html/reptooln_admin/app/cache/dev/assetic/routing.yml', 'yaml') in DelegatingLoader.php line 45
at DelegatingLoader->load('/var/www/html/reptooln_admin/app/cache/dev/assetic/routing.yml', 'yaml') in DelegatingLoader.php line 58
at DelegatingLoader->load('/var/www/html/reptooln_admin/app/cache/dev/assetic/routing.yml', 'yaml') in classes.php line 11649
at Router->getRouteCollection() in classes.php line 11619
at Router->getGeneratorDumperInstance() in classes.php line 11600
at Router->getGenerator() in classes.php line 11545
at Router->generate('_profiler', array('token' => 'ccd0d6')) in WebDebugToolbarListener.php line 66
at WebDebugToolbarListener->onKernelResponse(object(FilterResponseEvent), 'kernel.response', object(TraceableEventDispatcher))
at call_user_func(array(object(WebDebugToolbarListener), 'onKernelResponse'), object(FilterResponseEvent), 'kernel.response', object(TraceableEventDispatcher)) in WrappedListener.php line 61
at WrappedListener->__invoke(object(FilterResponseEvent), 'kernel.response', object(ContainerAwareEventDispatcher))
at call_user_func(object(WrappedListener), object(FilterResponseEvent), 'kernel.response', object(ContainerAwareEventDispatcher)) in classes.php line 12147
at EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.response', object(FilterResponseEvent)) in classes.php line 12080
at EventDispatcher->dispatch('kernel.response', object(FilterResponseEvent)) in classes.php line 12241
at ContainerAwareEventDispatcher->dispatch('kernel.response', object(FilterResponseEvent)) in TraceableEventDispatcher.php line 112
at TraceableEventDispatcher->dispatch('kernel.response', object(FilterResponseEvent)) in bootstrap.php.cache line 3049
at HttpKernel->filterResponse(object(Response), object(Request), '2') in bootstrap.php.cache line 3044
at HttpKernel->handleRaw(object(Request), '2') in bootstrap.php.cache line 2991
at HttpKernel->handle(object(Request), '2', true) in bootstrap.php.cache line 3140
at ContainerAwareHttpKernel->handle(object(Request), '2', true) in ExceptionListener.php line 58
at ExceptionListener->onKernelException(object(GetResponseForExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
at call_user_func(array(object(ExceptionListener), 'onKernelException'), object(GetResponseForExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher)) in WrappedListener.php line 61
at WrappedListener->__invoke(object(GetResponseForExceptionEvent), 'kernel.exception', object(ContainerAwareEventDispatcher))
at call_user_func(object(WrappedListener), object(GetResponseForExceptionEvent), 'kernel.exception', object(ContainerAwareEventDispatcher)) in classes.php line 12147
at EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener)), 'kernel.exception', object(GetResponseForExceptionEvent)) in classes.php line 12080
at EventDispatcher->dispatch('kernel.exception', object(GetResponseForExceptionEvent)) in classes.php line 12241
at ContainerAwareEventDispatcher->dispatch('kernel.exception', object(GetResponseForExceptionEvent)) in TraceableEventDispatcher.php line 112
at TraceableEventDispatcher->dispatch('kernel.exception', object(GetResponseForExceptionEvent)) in bootstrap.php.cache line 3061
at HttpKernel->handleException(object(FileLoaderLoadException), object(Request), '1') in bootstrap.php.cache line 2997
at HttpKernel->handle(object(Request), '1', true) in bootstrap.php.cache line 3140
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in bootstrap.php.cache line 2384
at Kernel->handle(object(Request)) in app_dev.php line 14

问题出在哪里?我做错了什么?我正在尝试设置 NelmioApiDoc 和 FOSRestBundle

编辑 1

我已经修复了上一个问题,但得到了另一个类似的问题。这是我所做的更改。

/app/config/routing.yml

#PDOne 
# just leave in .yml file
pdone:
    resource: "@PDOneBundle/Resources/config/routing.yml"

# comment this out just for find where is the problem
#template:
#    resource: "@TemplateBundle/Controller/"
#    type:     annotation
#    prefix:   /

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

NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /api/doc

#SonataAdmin
admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /admin

_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin

/src/PDI/PDOneBundle/Resources/config/routing.yml

#sets this one as annotation
pdone:
    type:     annotation
    prefix:   /
    resource: "@PDOneBundle/Controller/"

#this ones will be for restful API
companies:
    type: rest
    prefix: /api/v1/companies
    resource: PDOneBundle\Controller\Rest\CompanyRestController

错误改成这样:

classes.php 第 13960 行中的 FileLoaderImportCircularReferenceException: 检测到圆形参考 “/var/www/html/reptooln_admin/app/config/routing_dev.yml” ("/var/www/html/reptooln_admin/app/config/routing_dev.yml" > “/var/www/html/reptooln_admin/app/config/routing.yml” > "/var/www/html/reptooln_admin/src/PDI/PDOneBundle/Resources/config/routing.yml"

"PDOneBundle\Controller\Rest\CompanyRestController" > "/var/www/html/reptooln_admin/app/config/routing_dev.yml")。

/src/PDI/PDOneBundle/Resources/config/routing.yml 的问题出在哪里?不能在同一个 YML 文件中使用 annotationrest 类型?我该如何处理?

【问题讨论】:

【参考方案1】:

循环引用错误其实是错误的,是加载路由时出错导致的(错误触发控制器调用,控制器要求加载路由,路由加载再次触发错误,...)。

您应该检查 PDOneBundle 和 TemplateBundle 控制器是否存在路由错误,例如缺少 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route 和此类错误。

【讨论】:

如果一切正常呢?我的意思是每个控制器都包含该路径 @ReynierPM 我刚刚发现错误可能在您的应用程序中无处不在。尝试更新 symfony/symfony 以查看更多信息。 您对查看更多信息是什么意思?我只是更新了作曲家依赖项,并且所有这些都更新了(composer update symfony/symfony ... Nothing to install or update)我发现了几个主题,例如this 其中@nicholas-masters 将此设置为捆绑包中的问题,这可能是原因? 我在尝试从未添加到 AppKernel.php 的捆绑包中加载路由时遇到此错误(由两个分支合并引起的错误) - 应该先检查一下。【参考方案2】:

感谢 Symfony2 上的用户 group 我找到了解决方法,我将在这里分享。经过长时间的研究,我发现了this SO 主题等,是的,没有提及注释和混合配置文件或导致循环引用的任何内容,简而言之,我只是删除了这个:

companies:
    type: rest
    prefix: /api/v1/companies
    resource: PDOneBundle\Controller\Rest\CompanyRestController

来自每个地方,只依赖于注释,这对我有用。这无助于我找到真正的问题,但至少让我的应用程序再次运行。希望这可以帮助任何有同样问题的人

【讨论】:

以上是关于在 routing_dev.yml 中检测到循环引用的主要内容,如果未能解决你的问题,请参考以下文章

英特尔引脚:分析例程检测到 ah 寄存器而不是 rsp (REG_STACK_PTR)

stm32外部中断引脚模式改变

Pandas - 在循环中应用多索引标签

为啥循环在这里比索引好?

如何在引导轮播中使用 for 循环

SRAM存储器芯片地址引脚线短路检测方法