升级到 Symfony flex (3.4) - 有很多包时出现问题

Upgrade to Symfony flex (3.4) - Problems when there are many bundles

我有一个使用 symfony 3.4 的应用程序,我正在将其更新为 flex,然后转到版本 4。 问题是我有很多捆绑包,而在 FLEX 中它们不能与这些捆绑包一起使用...所以我正在寻找一种方法来维护我的捆绑包...

这是我的 SRC 文件夹中的内容(控制器、实体和存储库为空):

> SRC
      > CONTROLLER
      > ENTITY
      > REPOSITORY
      > Kernel.php
      > .htaccess
      > H360 (the place of my bundles)
            > comercialBundle
            > jasperBundle
            > generalBundle
            > ...

这是 returns 给我的错误消息:

In FileLoader.php line 168:
                                                                                                                                                                                                                                                                        
  Expected to find class "App\H360\JasperBundle\Controller\DefaultController" in file "C:\inetpub\wwwroot0forhotels\src/H360\JasperBundle\Controller\DefaultController.php" while importing services from resource "../src/*", but it was not found! Check the name  
  space prefix used with the resource in C:\inetpub\wwwroot0forhotels\config/services.yaml (which is loaded in resource "C:\inetpub\wwwroot0forhotels\config/services.yaml").                                                                                     
                                                                                                                                                                                                                                                                        

In FileLoader.php line 157:
                                                                                                                                                                                                                                                                        
  Expected to find class "App\H360\JasperBundle\Controller\DefaultController" in file "C:\inetpub\wwwroot0forhotels\src/H360\JasperBundle\Controller\DefaultController.php" while importing services from resource "../src/*", but it was not found! Check the name  
  space prefix used with the resource.  

所以这是我的“services.yaml”文件的一部分(我知道这不对):

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

首先将 H360 添加到 App 下的排除部分。尝试自动装配完整的捆绑包不仅会导致那些 App 前缀错误,而且还会带来相当多的乐趣。希望你的包已经在工作了,所以你不需要自动装配它们。事实上,您可能会考虑完全关闭自动装配,直到您的应用程序正常运行。

您可能会遇到 composer.json 的 psr4 部分的问题。您需要设置自动加载(不是自动装配)以便 类 可以加载。