我对这个循环参考问题感到疯狂,但我无法找到我做错的事情。这是/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尝试了一些网址时出现此错误:
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 \控制器\休息\ CompanyRestController" > " /var/www/html/reptooln_admin/app/config/routing_dev.yml")
/src/PDI/PDOneBundle/Resources/config/routing.yml
的问题在哪里?在同一个YML文件中无法生成annotation
和rest
种类型?我该如何处理?
答案 0 :(得分:2)
循环引用错误实际上是错误的,由加载路径时的错误引起(错误触发控制器调用,控制器需要加载路由,路由加载触发错误,......)。
您应检查PDOneBundle和TemplateBundle控制器是否存在路由错误,例如缺少use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
和此类错误。
答案 1 :(得分:0)