"enable_annotations on the validator cannot be set as Annotations support is disabled" 在 symfony 中

"enable_annotations on the validator cannot be set as Annotations support is disabled" in symfony

我刚刚(成功)创建了一个包,当我准备通过控制台创建一个实体时,发生了这种情况(也有 clear:cache):

[LogicException]
"enable_annotations" on the validator cannot be set as Annotations support is disabled.

mi config.yml 长得像

framework:
    validation: { enable_annotations: true }
    serializer: { enable_annotations: true }

当我评论验证选项时抛出相同的异常但使用序列化程序

当我评论两者时,它变成了 ServiceNotFoundException

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] The service "routing.loader" has a dependency on a non-existent service "an notation_reader".

什么问题,我用的是symfony 3.3.11

您通常还需要启用注释支持。一旦 Doctrine\Common\Annotations\Annotation class 出现,就会自动发生这种情况。为此,您需要确保安装 doctrine/annotations 软件包。