如何在yaml中写入反斜杠
我正在尝试将 zend 框架配置文件从 application.ini 重写为 application.yml 格式,但我遇到了一些无法解决的问题。
在 application.ini 中我有这个:
pluginPaths.Bisna\Application\Resource\ = "Bisna/Application/Resource"
并且它有效。但是,如果我尝试将其写入 yaml 文件,则会收到有关语法不受支持的错误,
pluginPaths:
Bisna\Application\Resource\: Bisna/Application/Resource
我尝试了很多方法来解决此问题,但没有成功。
有什么想法吗?
I'am trying to rewrite zend framework configuration file from application.ini to application.yml format and I have some unsolvable problem for me.
in application.ini i have this:
pluginPaths.Bisna\Application\Resource\ = "Bisna/Application/Resource"
and it works. But if I try it write to yaml file I get an error about unsupported syntax
pluginPaths:
Bisna\Application\Resource\: Bisna/Application/Resource
I tried so much ways to solve this, but no worked..
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来
Zend_Config_Yaml
不支持键名称中的反斜杠。源代码中的相关行如下:(Zend/Config/Yaml.php,ZF 1.11.11 中的第 313 行)。它仅匹配 YAML 键名称的
[A-Za-z0-9_]
。解析方法与
Zend_Config_Ini
不同,后者使用对parse_ini_file()
PHP 函数的调用。这就是它使用 .ini 文件的原因。所以,我认为没有任何简单的解决方案,除非你想修改ZF源代码(我不推荐)。
希望有帮助,
It seems that
Zend_Config_Yaml
doesn't support the backslash in the key names. The relevant line in the source code is the following:(Zend/Config/Yaml.php, line 313 in ZF 1.11.11). It's matching only
[A-Za-z0-9_]
for the YAML key names.The parsing method is different from
Zend_Config_Ini
, which uses a call to theparse_ini_file()
PHP function. That's why it was working with .ini files.So, I don't think there is any easy solution, unless you want to modify the ZF source code (which I don't recommend).
Hope that helps,