Skip to content
Advertisement

Error framework-extra-bundle Anotation “Unable to parse file […] The XML file is not valid.”

There is a recurring error in my Symfony projects since a few months. Every time a file at the root of the project is edited (even a space add in an a.txt file will reproduce the bug), I get this error.

Unable to parse file “[RootPath]vendorsensioframework-extra-bundlesrcDependencyInjection/../Resources/configannotations.xml”: The XML file “[RootPath]vendorsensioframework-extra-bundlesrcDependencyInjection/../Resources/configannotations.xml” is not valid.

XML error

The error is remove with the command line symfony console cache:clear.

I think this error is linked to PhpStorm because I get it when I edit a root file with it, but the error is not reproducible when I edit a root file with VSCode or Notepad++.

I am using PhpStorm version 2021.2 and also tried with 2021.1.4 and 2020.3.3. I tried to disable all PhpStorm plugins.

The project is made with Symfony 5.3 but the error is reproduced with an older project using Symfony 5.1

Does someone knows how to resolve this or have an idea of what I could try to solve it?

Edit:
Here is the content of 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="SensioBundleFrameworkExtraBundleEventListenerControllerListener">
            <tag name="kernel.event_subscriber" />
            <argument type="service" id="annotation_reader" />
        </service>
    </services>
</container>

I found no modification in the annotations.xml file before, during and after the error.

Edit2:

With more test, this bug is reproduced every time a file is deleted or created at the root even with another tool like VS Code or Windows explorer.

The error is produced on modification only with PhpStorm, so I guess it create and delete a temp file or something similar when editing a file.

Advertisement

Answer

The error seems to come from IIS, Symfony and PHP version 8.0.8 and 8.0.10 (Others versions could cause the same issue).

Changing the IIS server’s PHP version to 8.0.0 prevents the error from occurring.

Advertisement