I am working on a PHP website where I have just added a switch for what environment it is running in – development for when it is running on my local site, and production when it is running live on the web host:
<?php
define('ENV','development');
//or
define('ENV','production');
I have the site under VC with Mercurial, and usually simply deploy my site with hg push (the server runs hg too), however, with the addition of this switch, the “production” site will always differ from the “development” site in that the version deployed live will always be set to production instead of development.
This means my deployment process goes from
- Develop
- Test
hg commit -m "Made changes"hg pushssh host hg update- Go to 1.
to
- Develop
- Test
hg commit -m "Made changes"- Change
developmenttoproduction - `hg commit -m “dev -> prod”
hg pushssh host hg update- (later:) Change
production->development hg commit -m "prod -> dev"- Go to 1.
Which is obviously not great.
Is there some way to keep one insulated from the other, so that the live site will always be set to production and my local copy set to development?
Instead of having a switch, have a development branch and a production branch.