我試圖將一個文件包含到 Symfony 4 路由中,但無法弄清楚放入 Bundle 名稱的正確方法是什么。我的路線.yml:icatcher_builder: # loads routes from the given routing file stored in some bundle resource: '@ICatcher/Builder/Resources/config/routes.yaml'我的 bundles.php:App\ICatcher\Builder\Builder::class => ['dev' => true, 'test' => true],我得到這個錯誤:在渲染模板期間拋出異常(“Bundle“ICatcher”不存在或未啟用。也許您忘記將其添加到 App\Kernel.php 文件的 registerBundles() 方法中?在@ICatcher 中) /Builder/Resources/config/routes.yaml(從“[PATH]\config/routes.yaml”導(dǎo)入)。確保“ICatcher/Builder/Resources/config/routes.yaml”包已正確注冊并在應(yīng)用程序內(nèi)核類中加載。如果捆綁包已注冊,請確保捆綁包路徑“@ICatcher/Builder/Resources/config/routes.yaml”不為空?!保?。如果我只是將路由復(fù)制到主 route.yml 文件中而不是包含外部資源 - 一切正常。
1 回答

四季花海
TA貢獻(xiàn)1811條經(jīng)驗 獲得超5個贊
Symfony 有嚴(yán)格的 Bundle 類命名規(guī)則,我在文檔中找到了這些規(guī)則: https ://symfony.com/doc/current/bundles/best_practices.html
因此,我的 Bundle 類現(xiàn)在從App\ICatcher\Builder\Builder
to重命名,App\ICatcher\Builder\ICatcherBuilder
并且文件以相同的方式重命名ICatcherBuilder.php
并且可以正常工作。
- 1 回答
- 0 關(guān)注
- 139 瀏覽
添加回答
舉報
0/150
提交
取消