As web development projects get more complex, we as developers find ourselves straying from the standard LAMP stack or similar to include tools like noSQL databases and message queues.
Our favoured tools like WAMP and MAMP are becoming outdated and harder to use for projects more complex than a WordPress website or a simple PHP / Java / Ruby project.
Many people solve this problem by simply hosting these tools on cloud services like AWS or DigitalOcean. This is a viable solution, but after a while some drawbacks do become clear:
Hosting these services externally can cause them to be slow, possibly hiding performance issues in your applications.
These services will only work if you have an internet connection. This means no working on the train / plane, and no working if your internet cuts out.
Making a change to the configuration can cause breakage for anybody else using the tool for their development environment. This usually means you need to duplicate the instance, which costs money, and merging these changes doesn’t always work as issues can arise.
This is where tools like Virtualbox, Vagrant and PuPHPet come to the rescue. Making setting up environments a cinch!
What is Vagrant?
Taken straight from the vagrant website, Vagrant is “a tool for building complete development environments. With an easy-to-use workflow and focus on automation”.
This is achieved using simple and easy to modify scripts that can range from a simple “vagrantfile” to a whole provisioning system like Puppet or Ansible.
Why should I use Vagrant over WAMP / MAMP?
So you might be thinking “This is great and all, but I have WAMP/WAMP and that works great for me and my team. Why should I use vagrant over that?”.
This is an excellent question that has been answered many times all over the internet, probably far better than I ever could. Instead here are a few of my favourite reasons for using Vagrant:
- Vagrant allows easy sharing of development environments between machines, team members and contractors. This essentially makes the words “it works on my machine!” a thing of the past.
Vagrant makes installing tools like noSQL databases and message queues into your development environment a very painless process, since you are just installing them into a standard Linux environment.
Vagrant allows you to have completely segregated development environments allowing you to utilise different versions of PHP for example, or completely different Nginx or Apache configurations. This can be a godsend if you are working on more than one project at a time and you don’t want to risk breaking another project while making changes to your local development environment.
Vagrant is excellent for open source projects. It allows you to provide a standard development environment for your contributors to work from, lowering the barrier to entry and allowing others to contribute to your project quicker.
If you are developing using the Laravel framework then you also have access to the “Homestead” vagrant box, which has almost anything you could ever need for developing a Laravel application bundled into one simple to use box, it’s kind of awesome!
Stay tuned for part two where we'll dive into getting your own Vagrant setup up and running.