You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Symfony 4.2.8, extending AbstractController generates an AnnotationException with the following error message:
Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation @required in method Symfony\Bundle\FrameworkBundle\Controller\AbstractController::setContainer() was never imported. Did you maybe forget to add a "use" statement for this annotation? in /home/ubuntu/public_html/mikehhero/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54
We are using SensioFrameworkExtra bundle with @Route, @Security and @IsGranted annotations without problems. This was our first attempt to use the AbstractController and autowiring instead of the deprecated Controller.
I assume it is a misconfiguration but I'm not sure where to look to resolve it.
The text was updated successfully, but these errors were encountered:
The problem did not reproduce in a small application which is why I was pretty sure it was a misconfiguration. After a few hours of debugging I diagnosed and solved the problem. I'll post the answer here for other people who run into the issue.
This project in question is long-lived and at one point used Symfony 2. Consequently we had defined our own annotations.reader service in the services.yml file:
This was overriding the service definition provided by symfony/framework-bundle in the annotations.xml file:
<!-- vendor/symfony/framework-bundle/Resources/config/annotations.xml -->
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader">
<call method="addGlobalIgnoredName">
<argument>required</argument>
<!-- dummy arg to register class_exists as annotation loader only when required -->
<argument type="service" id="annotations.dummy_registry" />
</call>
</service>
Since the overridden service didn't add the required keyword the DocParser thew an AnnotationException due to a semanticalError when it encountered the @required annotation in the AbstractController::setContainer method.
In Symfony 4.2.8, extending AbstractController generates an AnnotationException with the following error message:
Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation
@required
in method Symfony\Bundle\FrameworkBundle\Controller\AbstractController::setContainer() was never imported. Did you maybe forget to add a "use" statement for this annotation? in /home/ubuntu/public_html/mikehhero/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54We are using SensioFrameworkExtra bundle with
@Route
,@Security
and@IsGranted
annotations without problems. This was our first attempt to use the AbstractController and autowiring instead of the deprecated Controller.I assume it is a misconfiguration but I'm not sure where to look to resolve it.
The text was updated successfully, but these errors were encountered: