首页 文章

新Symfony包上的ClassNotFound

提问于
浏览
0

我想添加一个包来在我的Symfony 3.2.1应用程序上创建一个博客 . 我尝试创建一个捆绑而不生成它,所以我已经完成了与默认的“AppBundle”相同的结构:我在“src”下创建了一个“BlogBundle”文件夹,在它下面创建了一个“BlogBundle.php”文件包含与AppBundle.php文件相同的代码(更改名称...) . 然后我在AppKernel.php文件中声明它 .

但是我的应用程序上有一个"ClassNotFound" . 所以我删除了所有内容并使用控制台 generate:bundle 脚本 . 但即使有脚本,我也有同样的问题......

该包在AppKernel中声明,代码为 new BlogBundle\BlogBundle()

错误(应用程序的dev.log文件中没有错误):

ClassNotFoundException in AppKernel.php line 41: Attempted to load class
"BlogBundle" from namespace "BlogBundle".
Did you forget a "use" statement for another namespace?

in AppKernel.php line 41
at AppKernel->registerBundles() in Kernel.php line 403
at Kernel->initializeBundles() in Kernel.php line 113
at Kernel->boot() in Kernel.php line 165
at Kernel->handle(object(Request)) in app_dev.php line 43
at require('/media/jon/Projets/Projets/heroDelHumanite/Sylius/boutique/web/app_dev.php') in router_dev.php line 40

`

有人知道这个问题吗?

谢谢 !

1 回答

  • 0

    好吧,我发现了问题:在composer.json的autoload param中,我只有src / AppBundle et pas“src /”,所以,我想,只有AppBundle是自动加载的:

    "autoload": {
            "psr-4": {
                "AppBundle\\": "src/AppBundle/"
            },
    

    感谢你的帮助 !

相关问题