1

我对这个循环参考问题感到疯狂,我找不到我做错了什么。这是的内容/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

每当我在devenv 尝试一些 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 文件中生活annotation和输入?rest我该如何处理?

4

2 回答 2

2

循环引用错误实际上是一个错误,由加载路由时出错引起(错误触发控制器调用,控制器需要加载路由,路由加载再次触发错误,...)。

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

于 2015-05-04T22:07:49.763 回答
0

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

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

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

于 2015-05-05T21:02:42.287 回答