php - 升级到 Symfony flex (3.4) - 有很多捆绑包时的问题
问题描述
我有一个使用 symfony 3.4 的应用程序,我正在将其更新为 flex,然后转到版本 4。问题是我有很多捆绑包,而在 FLEX 中它们不适用于这些……所以我正在寻找一种方法维护我的包裹...
这是我的 SRC 文件夹中的内容(控制器、实体和存储库为空):
> SRC
> CONTROLLER
> ENTITY
> REPOSITORY
> Kernel.php
> .htaccess
> H360 (the place of my bundles)
> comercialBundle
> jasperBundle
> generalBundle
> ...
这是它返回给我的错误消息:
In FileLoader.php line 168:
Expected to find class "App\H360\JasperBundle\Controller\DefaultController" in file "C:\inetpub\wwwroot\360forhotels\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\wwwroot\360forhotels\config/services.yaml (which is loaded in resource "C:\inetpub\wwwroot\360forhotels\config/services.yaml").
In FileLoader.php line 157:
Expected to find class "App\H360\JasperBundle\Controller\DefaultController" in file "C:\inetpub\wwwroot\360forhotels\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 部分的问题。您需要设置自动加载(不是自动装配),以便可以加载您的类。
推荐阅读
- kubernetes - clusterIP 可以从其他节点访问吗?
- php - Centos 7 php 狂热
- animation - 单击矩形时使用 svg 动画降低矩形的不透明度
- sql - SQL Server:每个 GROUP BY 表达式必须至少包含一个不是外部引用的列
- php - 如何使用 php 和 fpdf 创建发票 pdf?
- javascript - 使用 datalist 打开一个新选项卡
- java - 如何将两个地图添加到列表中
- c# - 使用 ItemTemplate 扩展 ListBox
- javascript - 如何放大当前光滑幻灯片的图像?
- reactjs - 如何将多个文档添加到 Firebase 的集合中?