我有这个代码
services:
repo.game:
class: Doctrine'ORM'EntityRepository
factory_service: doctrine.orm.default_entity_manager
factory_method: getRepository
arguments:
- AppBundle'Entity'Game
file.upload.listener:
class: AppBundle'Listener'FileUploadListener
arguments: [@repo.game]
tags:
- { name: "kernel.event_listener", event: "oneup_uploader.post_upload", method: "onUpload" }
这在<=2.8,但在3.0中我收到了这个错误消息
[Symfony'Component'DependencyInjection'Exception'InvalidArgumentException] The file "/ext/thing/app/config/services.yml" does not contain valid YAML.
[Symfony'Component'Yaml'Exception'ParseException]
The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 14 (near "arguments: [@repo.game]").
我的/ext/thing/app/config/services.yml
文件中没有其他内容
参考yaml部分中的升级指南:
以@、`、|或>开头的无引号字符串会导致ParseException。
因此,尝试修改您的配置如下:
file.upload.listener:
class: AppBundle'Listener'FileUploadListener
arguments: ["@repo.game"]
tags:
- { name: "kernel.event_listener", event: "oneup_uploader.post_upload", method: "onUpload" }
希望这能帮助
第一个错误看起来像缩进,参数和标记中有2个缩进空间和4个缩进,请尝试在线测试yml。
第二符号3现在是严格的。您需要将参数服务[@repo.game]
中的引号添加到["@repo.game"]
目前,具有特殊字符的值必须用单引号而不是双引号包装。它是有效的yaml,但例如,它在symfony 的phpunit运行中引发了许多异常