duandao3265 2009-07-20 11:33
浏览 41
已采纳

关于PHP项目和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

  • 写回答

1条回答 默认 最新

  • douba1904 2009-07-20 15:57
    关注

    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:

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

    obviously, running this once the file is deployed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示