简体   繁体   English

有关Capistrano for PHP项目和config.php中默认部署任务的问题

[英]Questions about default deploy Task in Capistrano for PHP project and config.php

I'm having a full day understanding the use of Capistrano. 我整天都在了解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 :) 我实际上是想用它来部署我的许多php应用程序之一:)

If I have a config.php with an $env="development" variable. 如果我有一个带有$ env =“ development”变量的config.php。 Is there any way to make Capistrano change this variable for me to "production" instead? 有什么方法可以使Capistrano替我将此变量更改为“生产”吗? Or I should forget about it and symlink it to shared? 还是我应该忘记它,并将其符号链接到共享?

cheers Guillermo 欢呼吉列尔莫

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. 通过分支我的代码进行开发,登台和发布,我已经获得了相当积极的成果-但是我也看到了这样的情况:从外部分支进行合并(即3次)完全是大型项目的噩梦。

Alternatively, you might have config.php, config.php.live, etc - but this requires manual maintenance. 另外,您可能拥有config.php,config.php.live等-但这需要手动维护。

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: 如果您仍然想使用capistrano-您可以使用sed使用正则表达式更改该行:

sed -i 's/$env=\"development\"/$env=\"production\"/' config.php

obviously, running this once the file is deployed. 显然,一旦部署文件就运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM