douzheyo2617 2015-04-17 12:36
浏览 29
已采纳

将子域路由添加到Symfony时,FileLoaderImportCircularReferenceException

I am trying to route a subdomain to a specific bundle in Symfony2. Here's what I've got:

I added local domains to my hosts:

127.0.0.1    todolist.lc
127.0.0.1    manager.todolist.lc

I created a virtual host that forwards all subdomains to my Symfony installation:

<VirtualHost 127.0.0.1>
 ServerName todolist.lc
 ServerAlias *.todolist.lc
 DirectoryIndex app_dev.php
 DocumentRoot "C:\xampp\htdocs\todolist\web"
</VirtualHost>

I created a new Bundle to handle the subdomain manager.todolist.lc:

ManagerBundle

Now I am trying to set up the route to manager.todolist.lc:

frontend:
    resource: "@FrontendBundle/Controller/"
    type:     annotation
    prefix:   /

backend:
    resource: "@BackendBundle/Controller/"
    type:     annotation
    prefix:   /api

manager:
    host:     manager.todolist.lc
    resource: "@ManagerBundle/Controller/"
    type:     annotation
    prefix:   /

Now after I added the manager route I get a FileLoaderImportCircularReferenceException on every route there is.

I also tried to use a prefix, but this also gives the Exception:

manager:
    resource: "@ManagerBundle/Controller/"
    type:     annotation
    prefix:   /manager

I can't figure out what I am missing. What am I doing wrong? If you need any more info, just ask for it in the comments and I'll provide it.

  • 写回答

1条回答 默认 最新

  • doufendi9063 2015-04-17 13:34
    关注

    Ok. Here's what I was missing:

    1. I forgot to load the bundle into the AppKernel

    Obviously, this is very important:

    new FrontendBundle\FrontendBundle(),
    new BackendBundle\BackendBundle(),
    new ManagerBundle\ManagerBundle(),
    

    2. The subdomain needs to be declared before the main domain

    After I loaded the bundle into the AppKernel the application would still route to the FrontController. I solved this by changing the order of my routes:

    manager:
        host:     manager.todolist.lc
        resource: "@ManagerBundle/Controller/"
        type:     annotation
        prefix:   /
    
    frontend:
        resource: "@FrontendBundle/Controller/"
        type:     annotation
        prefix:   /
    
    backend:
        resource: "@BackendBundle/Controller/"
        type:     annotation
        prefix:   /api
    

    After changing the order of the routes both manager.todolist.lc and todolist.lc worked.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么