Vagrant is a tool for creating and managing virtual environments that help many developers not have to care about the “works on my machine…” problem. Vagrant creates reusable development systems that can be used again and again, helping you keep your system clean of too many installations.
When you are focused on development and lack the skills of a sys admin, the best thing to do (if you are going to use Vagrant during development) is to try another way of setting up your Vagrant configuration.
When it comes to PHP development, there are some online services that simplify the setup and configuration of these Vagrant virtual machines. Here is a list of some of these services.
PuPHPet is probably the most “famous” of these services, and probably the most “specialized” one of them. It gives you the ability to host the VM on your local machine, on Digital Ocean, Rackspace or Amazon Web Services. You get to add forwarded ports with just a click of a button, and sharing source folders is as easy as that too. You can customize the firewall by setting rules and removing them as needed. As for web servers, you can choose between Apache and Nginx, choosing aliases and ports where to access the application.
When it comes to programming languages, PuPHPet is not all about PHP. Besides PHP, you can choose to install Python, Ruby, NodeJS and HHVM. You can’t install both PHP and HHVM, since the service doesn’t allow this – use Homestead Improved for running both at the same time. When installing HHVM, you can also choose to install the nightly release, which gives you the possibility of testing Facebook’s Hack language.
As for databases, PuPHPet has the biggest repository of those, with 6 different databases available. You can choose between MySQL/MariaDB (can’t have both of them), PostgreSQL, Redis, SQLite and MongoDB. You can chose to install Adminer for DB management, but don’t install it onto the production server.
All that PuPHPet wants from you is that you use a Vagrant version not lower than 1.6. Also, you need VirtualBox in order to use the configurations on your local machine. You can find the source code of PuPHPet on this GitHub repo and a more in-depth guide here.
Protobox is another online Vagrant service. There are many reasons to use Protobox. It actually started as a fork of PuPHPet, but turned out to be a complete other project, due to some issues related to Puppet (not PuPHPet). Protobox has grown into a great service that helps create Vagrant configurations for web application development.
When using Protobox, you can choose from a list of application types:
- Laravel (which also has its own Vagrant configuration – Homestead)
- WordPress (which also has VVV – Varying Vagrant Vagrants)
You can add more than one of these applications to the configuration. As for the web servers, both Apache and Nginx are available. You can choose only three languages: PHP, HipHop (with HHVM) and Ruby.
At the time of writing this, Protobox supports only MySQL and MariaDB, but other databases, such as PostgreSQL, MongoDB, Redis and Riak are coming soon. Tools such as Ngrok and NewRelic tools (PHP Agent and Node Agent) can be installed by ticking a checkbox.
You can find the source code for Protobox in their GitHub repo.
Phansible is somewhat simpler than the above services. It allows both Apache and Nginx, with HHVM only when you choose Nginx. You can’t choose any other language than PHP, but you can chose between versions of PHP. Also, you can’t choose any other database other than MySQL.
When you’re predetermined to use only Apache/Nginx, PHP and MySQL, Phansible doens’t differ that much from the other services above. Otherwise, you would have to install other tools manually.
Rove is probably the simplest of them all. You can choose any of the typical configurations, Rails and LAMP, or you can create your configuration manually.
Rove supports CouchDB, MongoDB, MySQL, PostgreSQL, Redis and SQLite as databases. You can select as many as you want of them. It also supports the same languages as PuPHPet, all except HHVM.
5. Customized configurations
There are also some other Vagrant configurations that are case-specific, i.e. for a single PHP framework.
I would mention here Laravel’s Homestead, which makes Laravel development a piece of cake, both front and back end. It comes with PHP5.6, Nginx as the web server, both MySQL and PostgreSQL; and NodeJS, with Bower, Grunt and Gulp for the front-end development. There’s an improved version of Homestead here.
Phalcon also has a Vagrant configuration, which saves you the time of installing it and configuring it in an existent server, although you can follow this quick tip to install Phalcon on a Homestead Improved instance.
Vagrant may be difficult to use sometimes, but is worth pursuing as it can be exceptionally useful. If you are tired of configuring your machine for every project you have, then Vagrant is the right tool for you. If you face problems while configuring your machine, then using a prepackaged vagrant box is the best answer to your problems. Any alternatives to the services above we’ve missed? Let us know!
Aldo is a Code-Lover and a student of Computer Engineering from Albania. His short-term goal is that of becoming a full-stack developer, focusing on Android, Ruby technologies and DevOps techniques.
The Principles of Beautiful Web Design, 4th Edition
Docker for Web Developers
HTML5 Games: Novice to Ninja