Tools That we Use – Part 2 – Virtualization
This post is the second part of our blog series in where we talk about the tools we use. Last time we covered the topic of Git, and today we are talking about Virtualization.
What is virtualization and why do we use it?
Virtualization is the process of running a virtual instance of a computer system in a layer abstracted from the actual hardware. A virtual instance, also known as a virtual machine, is an emulated equivalent of a computer system that runs within another computer system.
There are two main reasons why we use virtualization. The first one is the emulation property. The virtual machine can run on any computer regardless of hardware. In other words, there is no risk of hardware variation, and software is always developed in the same conditions.
The second one is that we can store the state of a virtual machine at any time. Storing a virtual machine state (better known as a snapshot) is a useful backup technique and it also provides portability of virtual machines between different hosts.
What do we use for virtualization?
Our virtualization workflow is made up of three components:
- Hypervisor, or hardware virtualization software, is computer software that creates and runs virtual machines. A computer on which the hypervisor runs is called a host machine. A virtual machine that runs within a hypervisor is called a guest machine. The hypervisor we use is Parallels Desktop for Mac.
- Vagrant is open-source software for building and maintaining portable virtual software development environments. Vagrant has an easy-to-use workflow focused on automation. It provides a simple, elegant way to manage and provision virtual machines.
- The Vagrant box is an easy-to-configure and portable work environment. We use Laravel Homestead pre-packaged Vagrant box that provides a development environment without requiring you to install PHP, a web server, or any other server software on your local machine. Vagrant boxes are completely disposable so there is no concern about messing up your local operating system. If something goes wrong, you can destroy and re-create the box.
Parallels Desktop for Mac
Parallels Desktop for Mac was the first software product to bring mainstream virtualization to Macintosh computers utilizing Apple-Intel architecture. The most recent version is version 16, released on August 11th, 2020. Version 16 brings support for the new macOS “Big Sur” architecture. It also brings easier export of a virtual machine in a compressed format ready for transfer to another Mac.
All virtual machines are managed through Parallels Control Center. With Control Center you can clone a virtual machine if you need an exact copy of it. You can make backups of virtual machines to protect yourself from data loss. As already mentioned, you can save a snapshot of a virtual machine at any time. If you don’t need a virtual machine anymore, you can permanently remove it from your computer. To make virtual machines more distinctive inside the Control Center you can also change the virtual machine icon or change the virtual machine name.
Vagrant and Laravel Homestead
Vagrant uses provisioners and providers to manage development environments. The provider (our hypervisor) is a service that Vagrant uses to set up and create virtual environments. Provisioners are tools that help us customize the configuration of virtual environments.
Vagrant sits on top of the virtualization software as a wrapper and helps the developer to easily interact with the provider. It is useful in software development because it isolates dependencies and their configuration within a single disposable, consistent environment. To make this possible, we write a Vagrantfile.
The primary function of Vagrantfile is to describe the type of machine required for a project and how to configure and provision it. Vagrant is meant to run within one Vagrantfile per project and it is supposed to be committed to version control. If you want to learn what version control is, check part 1 of the tools we use. This allows other developers involved to run the same development environments, against the same dependencies, all configured the same way regardless of the hardware and host OS. Just run vagrant up, and you will be on your way.
Although we can use any other pre-packaged Vagrant box, we use Laravel Homestead. Homestead has proven to be the best because it comes bundled with all the software necessary for the development of web applications.
By using Vagrant we significantly reduce the time needed for the preparation of our working environments. When using a pre-packaged Vagrant box there is no need for us to download the OS, manually install it, go inside the OS, and set up applications needed for software development. The creation of the work environment is made just by running a few commands. Running existing projects is even easier. Just download project files and run vagrant up.
We use Homestead as our box of choice, but you can visit this link to find the box that best suits your needs. Also, you are not limited to using Parallels as your provider, although our experience with Parallels showed us that it is faster and more reliable than its comparable providers.