开发与生产 fusionbox.xml
我正在使用 Coldfusion 开发 Fusebox 应用程序,并且有一个 fusebox .xml
文件,我希望生产服务器上的文件与开发服务器上的文件略有不同。由于该文件似乎只是一个 xml
文件(即:我不认为它可以是一个 cfm
文件),因此我似乎无法使用某些
逻辑。fusebox.xml
中的 if..else..
所以我想知道我的上述假设是否错误,或者是否有一种方法可以使用两个文件,一个用于开发,一个用于生产?
I'm working on a Fusebox application using Coldfusion, and there is a fusebox.xml
file which I'd like to be slightly different on the production server than it is on the development server. Since it appears that this file is just a xml
file (ie: I don't think it can be a cfm
file), it seems I cannot use some if..else..
logic within fusebox.xml
.
So I'm wondering if my assumption above is wrong, or if there is a way to use two files, one for development and one for production?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在使用
fusebox.xml
的旧项目中,我们使用名为server.xml
的配置的另一个副本。该文件通常不受源代码控制,因此可以轻松配置应用程序实例。它的结构与
fusebox.xml
非常相似,但仅包含我们想要为当前实例覆盖的属性,例如数据源或路径:在
fusebox.appinit.cfm
中> 或fusebox.init.cfm
(取决于此文件更改的频率或任何其他原因)此文件将被解析,并且application.fusebox
中的匹配条目将被更新。例如,这是执行此操作的函数:顺便说一句,为了安全起见,我们通常将它们重命名为
fusebox.xml.cfm
/server.xml.cfm
——它不使其成为 CFML 文件,但无需 Web 服务器技巧即可防止直接访问另外值得一提的是,在最新(自 2009 年以来)基于 Fusebox 的项目中,我们使用
Application.cfc
进行配置。这些是现代风格的应用程序,可以更好地控制初始化和其他可用作Application.cfc
方法的内容。通过这种方法,Fusebox 配置为
FUSEBOX_PARAMETERS
范围。覆盖其值甚至更容易,只需包含server.cfm
文件并使用FUSEBOX_PARAMETERS.datasource = "my_datasource"
放置一块纯 CFScript。In older projects with
fusebox.xml
we're using another copy of the config calledserver.xml
.This file is typically out of source control, so it allows easy configuration of application instances. It's structure is pretty the same as
fusebox.xml
, but includes only attributes which we want to override for current instance, for example datasource or paths:In the
fusebox.appinit.cfm
orfusebox.init.cfm
(depending how frequently this file is changed, or any other reasons) this file is parsed and matching entries inapplication.fusebox
are updated. For example, here's the function for doing this:BTW, for safety we usually rename them to the
fusebox.xml.cfm
/server.xml.cfm
-- it does not make it CFML file, but protects from direct access without web-server tricksAlso it worth mentioning that in latest (since 2009) Fusebox-based projects we've used
Application.cfc
for configuration. These are modern-style applications with much better control over the initialization and other stuff available asApplication.cfc
methods.With this approach Fusebox is configured as
FUSEBOX_PARAMETERS
scope. It's even easier to override its values, simply includeserver.cfm
file and put there a chunk of plain CFScript withFUSEBOX_PARAMETERS.datasource = "my_datasource"
.这就是我所做的:
显然,生产环境的应用程序名称与开发环境的应用程序名称不同。
Here is what I did:
And obviously the application name is different for the production environment than it is for the development environment.
我们不使用 Fusebox,但我们有类似的配置文件,这些文件从开发到测试再到生产都不同。我们只需将所有三个版本保存在存储库的不同目录中,并将所需的(生产)版本上传到生产服务器。由于这些文件很少更改,这对我们有用。
Fusebox docs 似乎没有指出使用不同
fusebox.xml
但也许 Fusebox 专家可以确认这一点。We don't use Fusebox but we have similar config files that are different from dev to test to production. We just keep all three versions in different directories in the repository and upload the required (production) version to the production servers. Since these files changes infrequently this works for us.
The Fusebox docs don't seem to indicate a way to use a different
fusebox.xml
but maybe an expert on Fusebox can confirm that.