为了账号安全,请及时绑定邮箱和手机立即绑定

Symfony 路由资源和 Bundle 名称

Symfony 路由资源和 Bundle 名称

PHP
温温酱 2022-07-02 16:52:16
我试图将一个文件包含到 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”导入)。确保“ICatcher/Builder/Resources/config/routes.yaml”包已正确注册并在应用程序内核类中加载。如果捆绑包已注册,请确保捆绑包路径“@ICatcher/Builder/Resources/config/routes.yaml”不为空。”)。如果我只是将路由复制到主 route.yml 文件中而不是包含外部资源 - 一切正常。
查看完整描述

1 回答

?
四季花海

TA贡献1811条经验 获得超5个赞

Symfony 有严格的 Bundle 类命名规则,我在文档中找到了这些规则: https ://symfony.com/doc/current/bundles/best_practices.html

因此,我的 Bundle 类现在从App\ICatcher\Builder\Builderto重命名,App\ICatcher\Builder\ICatcherBuilder并且文件以相同的方式重命名ICatcherBuilder.php并且可以正常工作。


查看完整回答
反对 回复 2022-07-02
  • 1 回答
  • 0 关注
  • 138 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号