symfony2 包自动加载失败

标签 symfony bundle

我碰巧得到了创作的所有 symfony 问题......

我想创建一个新项目。

我复制“symfony2”文件夹,然后重命名:

 php app/console generate:bundle

它说:

  Generating the bundle code: OK
  Checking that the bundle is autoloaded: FAILED
  Confirm automatic update of your Kernel [yes]? 
  Enabling the bundle inside the Kernel: OK
  Confirm automatic update of the Routing [yes]? 
  Importing the bundle routing resource: FAILED

  The command was not able to configure everything automatically.  
  You must do the following changes manually.                      

  - Edit the composer.json file and register the bundle
  namespace in the "autoload" section:

  Bundle MddevPsavBundle is already imported.

这是为什么呢?当我上次没有遇到这个问题时,我执行了相同的命令?

我该如何准确地解决这个问题?我应该在 composer.json 文件中添加什么??

我尝试过一些东西,但我得到:

  Fatal error: Class 'Mddev\PsavBundle\MddevPsavBundle' not found in
  /var/www/projetQ/app/AppKernel.php on line 22

最佳答案

如果您遇到问题:

The command was not able to configure everything automatically.  
You must do the following changes manually.

然后告诉你:

- Edit the composer.json file and register the bundle
namespace in the "autoload" section:

假设您已关注 bundle name conventions正确的话,那么您需要:

<小时/>

将新包添加到composer.json文件

"autoload": {
    "psr-0": {
        "currentbundle\\": "src/",
        "YOURNEWBUNDLE\\": "src/",            
    }
}

然后您需要再次在 Composer 上运行安装

composer -n install --dev

然后您应该自动加载两个包

关于symfony2 包自动加载失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13213010/

相关文章:

PHP (Symfony 4) rabbitmq 消费者命令作为守护进程

php - Symfony 3.4 - 检测到服务的循环引用

symfony - 从一个存储库到另一个存储库的Symfony大量 hydration

php - 单表实体生成

java - karaf 在组件工厂示例中不显示任何错误

php - 交响乐团 3 : I can't install ckeditor

java - OSGI bundle .bnd 文件和冲突的 import-package 语句

android - onActivityResult Intent 数据不正确

php - 从 Symfony/Twig 中的覆盖版本访问父模板

java - BundleActivator 方法未在 OSGi 中得到通知