关于 Capistrano 中 PHP 项目和 config.php 的默认部署任务的问题
我花了一整天的时间来了解 Capistrano 的使用。 这确实是一个很好的工具,可以节省我很多时间。 我实际上想用它来部署我的众多 php 应用程序之一:)
如果我有一个带有 $env="development" 变量的 config.php。 有什么方法可以让 Capistrano 为我更改此变量为“生产”吗? 或者我应该忘记它并将其符号链接到共享?
干杯 吉列尔莫
I'm having a full day understanding the use of Capistrano. Is really a nice tool that will save me lots of time. I'm actually wanting to use it to deploy one of my many php apps :)
If I have a config.php with an $env="development" variable. Is there any way to make Capistrano change this variable for me to "production" instead? Or I should forget about it and symlink it to shared?
cheers
Guillermo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我喜欢将此类配置文件分开 - 它使其更加具体和明确。 如何将它们分开和部署由您自行决定。 通过将代码分支用于开发、暂存和运行,我取得了相当积极的结果 - 但我也看到过从外部分支合并(即三次)对于更大的项目来说完全是一场噩梦的情况。
或者,您可能有 config.php、config.php.live 等 - 但这需要手动维护。
您的里程显然会有所不同,我的配置文件往往有多个部署之间不同的变量,因此,这一额外的架构是值得的。
如果您仍然想使用 capistrano 执行此操作 - 您可以使用 sed 使用正则表达式更改该行:
显然,在部署文件后运行此操作。
I like to keep such config files separate - it makes it more specific and explicit. How these are kept separate and deployed is at your own discretion. I've had fairly positive results by branching my code for development, staging, and live - but I've also seen situations where a merging in from an external branch (ie three times) is a complete nightmare on bigger projects.
Alternatively, you might have config.php, config.php.live, etc - but this requires manual maintenance.
Your miles will obviously vary, my config files tend to have more than one variable differing between deployments, and as such, this extra architecture pays for itself.
If you do still want to do it with capistrano - you can use sed to change that line using a regular expression:
obviously, running this once the file is deployed.