Vagrant Improvements in latest PhpStorm Update
With PhpStorm 7, we introduced built-in support for working with Vagrant, a tool which helps to create reproducible development environments. These scripted virtual machines can then be shared using a simple script, instead of having to share a full-blown virtual machine. These scripts can even be added to source control so virtual machine configurations can be versioned.
The latest PhpStorm 7.1.1 and 7.1.2 updates enhance IDE support for Vagrant with a number of new features! It’s now possible to specify the Vagrant instance folder, manage plugins, install and specify the provider to use and much more. Let’s go over our new toys!
This functionality is available in IntelliJ IDEA, WebStorm, RubyMine, PhpStorm, PyCharm and AppCode.
Specifying Vagrant instance folder
We’ve added support for configuring the instance folder. Before, the Vagrantfile and all other Vagrant specifics (like Puppet manifests) had to be placed in the project root to work in PhpStorm, often resulting in a messy project structure. With the latest update, we can now specify the instance folder where the IDE should look for Vagrantfile through Project Settings | Vagrant:
Manage Vagrant plugins through settings
There is more to be found under Project Settings | Vagrant! What about managing Vagrant plugins? We can make use of the toolbar buttons to install, uninstall and update plugins. Licenses can also be installed, for example for the VMWare Fusion Provider.
Providers support
When working with alternate Vagrant providers, we can now specify the provider through Project Settings | Vagrant. All installed providers will be available from the settings. Once selected, PhpStorm will execute all Vagrant commands using the provider configured.
Vagrant works with Oracle VirtualBox by default. Using providers, the virtualization platform can be changed and so virtual machines can be run by a system other than VirtualBox, such as VMWare or Amazon EC2. A list of available providers can be found on the Vagrant plugins list.
Vagrant Provision command
A Vagrantfile (the Vagrant configuration file) can contain a series of provisioners that can launch installation and configuration routines once a virtual machine is running. The Provision command invokes the configured provisioners on an already running Vagrant box, without having to first destroy the virtual machine.
The Tools | Vagrant menu now features this Provision command as well. Using it, we can run provisioning on a running environment.
Environment variables
Ever wanted to pass project-specific environment variables into the Vagrantfile? It’s easy! From the Project Settings | Vagrant we can specify environment variables to be set for the current project.
Once set, we can make use of them in our Vagrantfile using the #{ENV[‘name_of_variable’]} syntax:
Working with environment variables is really handy for doing several things, like:
- setting the Puppet node
- setting the Puppet environment
- setting custom facts
- setting AWS keys
- …
Multi-machine support
Working with Vagrant multi-machine environments? PhpStorm now supports this too. All we have to do is configure our multi-machine environment in the Vagrantfile and PhpStorm will make sure it all works when making use of the Tools | Vagrant menu.
We’ve updated our Vagrant tutorials page if you want to learn more about how this all works. Never tried Vagrant integration before? Here’s a short video that will guide you through.
Got feedback? We’re listening! Use the issue tracker, post your comments below or in our forums!
Develop with pleasure!
– JetBrains PhpStorm Team