Symfony 的 sfYaml::load 返回一个 stange 值
在 Symfony 项目中,我在 YML 文件中有以下 php 代码。我希望这段代码能够读取另一个 yml 文件并根据其值修改内容。但是,sfYaml::load 返回字符串而不是数组。有什么想法可能是为什么吗?
在下面的代码中,我期望 $s 包含一个数组,但它包含一个值为“../config/server_settings.yml”的字符串。
来自databases.yml:
dsn: mysql:host=myhost;dbname=mydbname<?php $s = sfYaml::load('../config/server_settings.yml');var_dump($s); ?>
In a Symfony project, I have the following php code inside a YML file. I was hoping this code would read another yml file and modify the content based upon its value. However, sfYaml::load is returning a string instead of an array. Any ideas why this might be?
In the following code, I expected $s to contain an array, but instead it contains a string with the value "../config/server_settings.yml".
From databases.yml:
dsn: mysql:host=myhost;dbname=mydbname<?php $s = sfYaml::load('../config/server_settings.yml');var_dump($s); ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来它将您的输入视为一串 yml 内容,可能是因为它找不到该文件。尝试使用完整路径或使用
is_file('../config/server_settings.yml')
进行快速调试It looks like it's treating your input as a string of yml content, possibly because it can't find the file. Try using the full path or some quick debugging with
is_file('../config/server_settings.yml')
您似乎正在尝试定义自定义设置。
也许此页面可以帮助您:
http://trac.symfony-project.org/wiki/HowToCacheCustomConfiguration
It looks like you're trying to define custom settings.
Perhaps this page might help you out:
http://trac.symfony-project.org/wiki/HowToCacheCustomConfiguration