2015-04-17 73 views
1

我試圖將子域路由到Symfony2中的特定束。下面是我得到了什麼:FileLoaderImportCircularReferenceException將子域路由添加到Symfony時

我加入地域到我的主機:

127.0.0.1 todolist.lc 
127.0.0.1 manager.todolist.lc 

我創建的所有子域名轉發到我的Symfony安裝一個虛擬主機:

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

我創建了一個新的捆綁來處理子域manager.todolist.lc:

ManagerBundle

現在我想建立路由到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: /

現在在我加入的經理路線我讓每一個有航線上FileLoaderImportCircularReferenceException。

我還試圖用一個前綴,但是這也給了異常:

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

我想不通,我錯過了什麼。我究竟做錯了什麼?如果您需要更多信息,只需在評論中詢問,我會提供。

回答

0

好的。下面是我缺少的是什麼:

1.我忘了捆綁裝入AppKernel

顯然,這是非常重要的:需要

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

2.子域聲明在主域名之前

將包加載到AppKernel後,應用程序仍然會路由到FrontController。我解決了這個改變我的路線順序:

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 

改變着manager.todolist.lc和todolist.lc工作路線的訂單後。