Symfony 3捆绑包的创建始终会抛出"Edit the composer.json file"(编辑composer.json文件). [英] Symfony 3 bundle creation always throws "Edit the composer.json file"

查看:170
本文介绍了Symfony 3捆绑包的创建始终会抛出"Edit the composer.json file"(编辑composer.json文件).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习symfony,每次我使用"php bin/console generate:bundle"命令创建捆绑包时,即使我默认情况下都保留所有内容,我仍然会收到此错误:

Hi I've been learning symfony, and every time I use the "php bin/console generate:bundle" command to create a bundle, even though I leave everything by default, I keep getting this error:

该命令无法自动配置所有内容. 您需要手动进行以下更改. 编辑composer.json文件并注册捆绑软件 自动加载"部分中的名称空间:

The command was not able to configure everything automatically. You'll need to make the following changes manually. Edit the composer.json file and register the bundle namespace in the "autoload" section:

在这里我在stackoverflow中看到,当您尝试将包放入不同于src的文件中时,会出现此问题,但事实并非如此,因为我告诉过您默认情况下,所有内容都保留下来;我的意思是,我只输入捆绑软件名称,然后继续按Enter,直到过程结束. 谁能告诉我我在做什么错?原因是什么? 谢谢

I saw here in stackoverflow that this problem shows up when you try to put the bundle in a file different than src, but that's not the case, as I told you I leave everything by default; I mean I just enter the bundle name and then keep pressing enter until the proccess ends. Can anyone tell me what am I doing wrong? what's the cause? Thanks

推荐答案

编辑composer.json:

Edit composer.json:

之前:

"autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle",
    },
    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
}'

之后:

"autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle",
        "NameofBundle\\": "src/NameofBundle"
    },
    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},

然后运行:

composer dump-autoload 

这篇关于Symfony 3捆绑包的创建始终会抛出"Edit the composer.json file"(编辑composer.json文件).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆