views:

239

answers:

1

Hello All,

I'm having a full day understanding the use of Capistarno. 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

A: 

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.

Simon Scarfe
I actually use my settings link this:$env = "dev"$conf["dev"]["db_host"] = "xxxxx"$conf["production"]["db_host"] = "yyyyyy"So, this command will be enought.tank you
Guillermo