At Engage we continuously try to improve our workflow, and as such, we have recently spent time on trying to figure out how we can improve the management and deployment process when working on web projects.
Our main goal was to determine a simple flow that makes it possible for multiple developers to collaborate on the same project using a version control system without requiring developers to have a local LAMP stack and with simple deployment to a dev, stage and production environment.
We decided to use git as the version control system of choice, primarily because of its cheap branching model and its distributed architecture.
How it works
The system works by heavily using server-side post-receive hooks to pull changes to the web server as soon as they are pushed to the remote git repository.
Each git branch corresponds to a separate URL which could be hosted in totally different hosting environments. Here are some examples for your reference:
“develop” branch: http://dev.mywebproject.com
“staging” branch: http://stage.mywebproject.com
“master” branch: http://mywebproject.com
A change to the develop branch is then as easy as committing a change and pushing it to the remote repository.
git commit -am ‘My new change’ git push origin develop
This could also easily be extended to support feature branches too. Let’s say that I need to work on a new landing page without disturbing the other developers who are currently working with minor changes in the development branch.
# Make sure we are on the develop branch git checkout develop # Create a new branch from the develop branch git checkout -b feature/newlandingpage develop
When pushing the branch for the first time to the remote repository, the post-receive hook will automatically handle creating a subdomain so the new landing page can be viewed at http://newlandingpage.feature.mywebproject.com
Speeding up the creation of new test projects
Another thing I, personally have been working on recently is a feature for GITLAB that enables me to quickly create a new web project from a template. This is done by allowing you to initialize a git repository from a template, right after the git project has been created in GITLAB.
Let’s say we pick CodeIgniter, Twitter Bootstrap and MySQL. A default CodeIgniter install will be copied to the repository. Twitter Bootstrap will be copied inside the CodeIgniter install with a default page, also a MySQL database/user will be created, and in addition to that, the CodeIgniter database config is updated to reflect the newly created database and user.
With this system it is easy to get started on a prototype of a new project without any compromises.