的管理路由我在Symfony2中一個初學者,我的工作Symfony2的項目,其中一種通用的捆綁,讓說CoreBundle,是管理所有路由(以這種形式,第一。域/ A-路線,second.domain/A-路線,third.domain/A-路線,...)的網站。現在,我一直在創造FirstBundle,SecondBundle,ThirdBundle與理念,以「傳遞」每個子域的路由的管理(firt,第二,第三,...)到相關的包。Symfony2的 - 涉及2種束
與路線從CoreBundle轉移到FirstBundle開始由編輯/app/config/routing.yml文件:
resource: "@ProjectFirstBundle/Resources/config/routing.yml"
prefix:/
host: "{subdomain}.{domain}"
defaults: { _controller: ProjectFirstBundle:Public:aroute }
domain: %project_domain%
requirements:
domain: "%project_domain%"
subdomain: 'first'
到:
resource: "@ProjectFirstBundle/Resources/config/routing.yml"
prefix:/
,然後創建FirstBundle /資源/ config/routing.yml文件,內容如下:
project_first_aroute:
path: /a-route
host: "{subdomain}.{domain}"
defaults: { _controller: ProjectFirstBundle:Public:aroute }
domain: %project_domain%
requirements:
domain: "%project_domain%"
subdomain: 'first'
當然,我已經創建了控件並使用與CoreBundle相同的模式查看文件(通過爲.twig文件進行適應 - 繼承)。因此,運行first.domain/a-route時會返回以下異常:
致命錯誤:未收集的異常'Symfony \ Component \ Yaml \ Exception \ ParseException'帶有消息'Unable to parse at line 15(附近「域:%project_domain%」)。'。在
任何建議,我怎麼能有效地實現我的目標是什麼?
在此先感謝您的幫助。
感謝您的回答。我仔細檢查了我的縮進並在%project_domain%上使用了引號,但仍然得到相同的異常。有時真正的問題不是例外中所述的內容;該例外情況可能只能提供識別問題的遠程線索。 –
是的,但不是解析器錯誤。它**必須**與Yaml File * imo *有關。 –
反正你知道命令'''應用程序/控制檯路由器:debug'''?請發佈那個輸出。 –