Continuous Development and Deployment of CodeIgniter using Git
Jul 13, 2013
I have had serious problems with continuously developing and deploying enhancements to web applications in CodeIgniter. The problem is that the deployment version has different set of configurations than the development version. Usually, these are sensitive configurations like database connection settings. So even if I missed a single configuration, the result is that the website is down. This made making quick enhancements very difficult. Git helped me come out of it.
Assume that you begin a new project and coded up to a point that you feel it’s time to deploy it. Now just create a separate branch named deploy
from master
at that point.
git branch deploy
git checkout deploy
Once you branched its time to change the configurations to suit the deployment environment. Usually in CodeIgniter it resides at the application/config path. Once changed, commit it.
git commit -m "Deploy config updated"
Now the first version of your application to be uploaded is ready. You can upload it to the server.
Now comes the enhancement part. When you need to enhance it. Just checkout the master
branch and start making enhancement to it.
git checkout master
Once the enhancement is over just merge it to deploy
branch.
git checkout deploy
git merge master
This makes sure that the deploy
branch is having all the enhancements made along with the configuration for the deployment which was there already in deploy
branch. Now you can just upload it to the server and the enhancement becomes live successfully. It is very very rare to face a merge conflict here as we are not going to change the settings every now and then. This will allow people concentrate on development and stop spending more time in deploying code enhancement.
Now you can just upload the files at the deploy
branch to the server. This is how I develop Encollege.
Now you can switch back and forth to master
and deploy
. When you develop locally use master
and you can run & test in local environment. When you want server uploadable version of your local development, checkout deploy
and merge master
to it.