在 symfony 中哪里存储用户可编辑的配置参数?
问题
我正在构建一个 symfony 应用程序,它可以根据用户的需求执行一些批处理作业。此作业是下载远程服务器上的所有文件,这些文件在用户上次启动此作业时不在该服务器上。为此,每次启动作业时,我都想存储当天的日期。但是,由于某些原因,该日期需要可由用户编辑。
问题是:存储此日期的最干净的位置在哪里?
可能的解决方案:
- 在 app.yml 中
- 优点:
- 方便用户编辑(但需要注意空格和缩进)
- 通常的配置位置
- 缺点:
- 需要 app.ylm 可由 PHP 写入,这可能不是一个好主意 &部署时还要做一件事。
- 优点:
- 在表格中
- 优点:
- 安全且易于从应用中读取和写入
- 缺点:
- 用户难以阅读
- 优点:
还有其他想法吗?
Question
I'm building a symfony app that does some batch jobs on user's demand. This job is to download all files on a distant server, that weren't on it the last time the user launched this job. To do that, everytime the job is launched, I'd like to store the date of the day. However, for some reasons, this date need to be editable by the user.
The question is : where is the cleanest place to store this date ?
Possible solutions :
- In the app.yml
- Pros:
- Easy for the user to edit (but need to take care of the spaces & indentation)
- Usual place for the config
- Con:
- Needs the app.ylm to be writtable by PHP, potentialy not a good idea & one more thing to do when deploying.
- Pros:
- In a table
- Pros:
- Secured, easy to read and write from the app
- Cons:
- Hard to reads for a user
- Pros:
Any other ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
csSettingsPlugin 可能会满足您的需求。这些设置公开给 Doctrine 模型,但缓存在具有可配置 TTL 的产品环境中。
csSettingsPlugin may do the trick regarding your needs. The settings are exposed to a Doctrine model but cached in prod environment with a configureable TTL.
由于这会在网站上线后发生变化,我当然也会说将其放入数据库中,而不是编辑 .yml 文件,如果 yml 由于任何原因损坏,则可能会导致整个网站关闭。
如果您关心编辑的方便性,您可以轻松提供一个简单的 Web 界面来更改数据库中的日期。
Since this will change after the site goes live, I would also certainly say put into a database rather editing the .yml files and potentially the whole site down if the yml become corrupted for any reason.
If ease of editing is a concern, you could easily provide a simple web interface for changing the date in the database.