错误框架外包注释 "Unable to parse file [...] The XML file is not valid."
Error framework-extra-bundle Anotation "Unable to parse file [...] The XML file is not valid."
几个月以来,我的 Symfony 项目中反复出现错误。每次编辑项目根目录下的文件时(即使 space 添加到 a.txt 文件中也会重现错误),我都会收到此错误。
Unable to parse file "[RootPath]\vendor\sensio\framework-extra-bundle\src\DependencyInjection/../Resources/config\annotations.xml":
The XML file "[RootPath]\vendor\sensio\framework-extra-bundle\src\DependencyInjection/../Resources/config\annotations.xml" is not valid.
错误已通过命令行删除 symfony console cache:clear
。
我认为这个错误与 PhpStorm 有关,因为我在用它编辑根文件时得到它,但是当我用 VSCode 或记事本++.
我使用的是 PhpStorm 版本 2021.2,还尝试了 2021.1.4 和 2020.3.3。我试图禁用所有 PhpStorm 插件。
该项目是使用 Symfony 5.3 制作的,但使用 Symfony 5.1 的旧项目重现了该错误
有人知道如何解决这个问题或知道我可以尝试解决什么问题吗?
编辑:
这是 annotations.xml 的内容:
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sensio_framework_extra.controller.listener" class="Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener">
<tag name="kernel.event_subscriber" />
<argument type="service" id="annotation_reader" />
</service>
</services>
</container>
我发现 annotations.xml 文件在错误之前、期间和之后都没有修改。
编辑2:
经过更多测试,即使使用 VS Code 或 Windows 资源管理器等其他工具,每次在根目录下删除或创建文件时都会重现此错误。
该错误仅在使用 PhpStorm 进行修改时产生,所以我猜它会在编辑文件时创建和删除临时文件或类似文件。
错误似乎来自 IIS、Symfony 和 PHP 版本 8.0.8 和 8.0.10(其他版本可能会导致同样的问题)。
将 IIS 服务器的 PHP 版本更改为 8.0.0 可防止错误发生。
在我的例子中(symfony6,php8.1),它有助于改变配置
sensio_framework_extra:
router: { annotations: false }
因为 sensio_framework_extra 包在默认配置中有弃用。
几个月以来,我的 Symfony 项目中反复出现错误。每次编辑项目根目录下的文件时(即使 space 添加到 a.txt 文件中也会重现错误),我都会收到此错误。
Unable to parse file "[RootPath]\vendor\sensio\framework-extra-bundle\src\DependencyInjection/../Resources/config\annotations.xml": The XML file "[RootPath]\vendor\sensio\framework-extra-bundle\src\DependencyInjection/../Resources/config\annotations.xml" is not valid.
错误已通过命令行删除 symfony console cache:clear
。
我认为这个错误与 PhpStorm 有关,因为我在用它编辑根文件时得到它,但是当我用 VSCode 或记事本++.
我使用的是 PhpStorm 版本 2021.2,还尝试了 2021.1.4 和 2020.3.3。我试图禁用所有 PhpStorm 插件。
该项目是使用 Symfony 5.3 制作的,但使用 Symfony 5.1 的旧项目重现了该错误
有人知道如何解决这个问题或知道我可以尝试解决什么问题吗?
编辑:
这是 annotations.xml 的内容:
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sensio_framework_extra.controller.listener" class="Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener">
<tag name="kernel.event_subscriber" />
<argument type="service" id="annotation_reader" />
</service>
</services>
</container>
我发现 annotations.xml 文件在错误之前、期间和之后都没有修改。
编辑2:
经过更多测试,即使使用 VS Code 或 Windows 资源管理器等其他工具,每次在根目录下删除或创建文件时都会重现此错误。
该错误仅在使用 PhpStorm 进行修改时产生,所以我猜它会在编辑文件时创建和删除临时文件或类似文件。
错误似乎来自 IIS、Symfony 和 PHP 版本 8.0.8 和 8.0.10(其他版本可能会导致同样的问题)。
将 IIS 服务器的 PHP 版本更改为 8.0.0 可防止错误发生。
在我的例子中(symfony6,php8.1),它有助于改变配置
sensio_framework_extra:
router: { annotations: false }
因为 sensio_framework_extra 包在默认配置中有弃用。