WebStorm 8.0.0 Web Help

Integration with Vagrant helps you create reproducible development environments defined by VagrantFile configuration files. To have the same environment set up on the machines of all the team members you only need to put the VagrantFile under your team version control. Any team member can set up the required environment by running the vagrant up command with the relevant VagrantFile. Vagrant support in WebStorm is provided through the Vagrant plugin that comes bundled with WebStorm.

On this page:

Glossary

In the context of WebStorm, the following terms are used to denote Vagrant-specific notions:

  • A Vagrant box in the WebStorm user interface or Vagrant base box in the current documentation is a box in the native Vagrant terminology. It denotes a pure image, a skeleton, on the base of which a specific environment is customized, provisioned, and deployed on your machine.
  • An instance is a virtual machine. In other words, it is a specific environment customized, provisioned, and deployed on your machine on the base of a Vagrant base box and in accordance with a VagrantFile. In other similar products and documentation, an instance can be referred to as virtual machine.
  • An instance folder is the folder where the relevant VagrantFile is stored after initialization and where WebStorm will look for it. By default, it is the project root folder.
Preparing to work with Vagrant
  1. Download and install Vagrant.
  2. Download and install the Oracle's VirtualBox.
  3. Make sure that the parent folders of the following executable files are added to the system PATH variable:
    • vagrant.bat or vagrant from your Vagrant installation. This should be done automatically by the Vagrant installer.
    • VBoxManage.exe or VBoxManage from your Oracle's VirtualBox installation.
  4. Install and enable the Vagrant repository plugin.

    The plugin is not bundled with WebStorm, but it is available from the WebStorm plugin repository. Once enabled, the plugin is available at the IDE level, that is, you can use it in all your WebStorm projects. See Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins for details.

  5. Open the Settings dialog box by choosing File | Settings and click Vagrant. On the Vagrant page that opens, specify the following:
    1. The Vagrant executable file. Because the parent folder of the executable file has been already added to the system PATH variable, type just the name of the executable.
    2. In the Instance Folder field, specify the fully qualified path to the directory where the VagrantFile is initialized and stored. A VagrantFile is a configuration file that defines the instance (virtual machine) you need. The file contains the virtual IP address, port mappings, and the memory size to assign. The file can specify which folders are shared and which third-party software should be installed. According to the VagrantFile your instance (virtual machine) is configured, provisioned against the relevant Vagrant base box, and deployed on your computer. A VagrantFile is created through the vagrant init command.

      When creation of an instance (virtual machine) is invoked either through the vagrant up command or through the Tools | Vagrant | Up menu option, WebStorm looks for the VagrantFile in the directory specified in the Instance folder field. For more information, see http://docs.vagrantup.com/v2/vagrantfile/.

      You can create a VagrantFile in any directory and appoint it as instance folder. If the field is empty, WebStorm will treat the project root as the instance folder and look for a VagrantFile in it.

    3. In the Vagrant Boxes area, configure a list of the predefined Vagrant base boxes available in WebStorm. Each item presents a Vagrant base box on which Vagrant configures and launches its instances (virtual machines). The entries of this list correspond to the output of the command vagrant box list.
      • To download a new base box, click the Add button add. In the dialog box that opens, specify the URL address to access the base box and the name to refer to it in WebStorm. By default, WebStorm suggests the URL to the lucid32 box.

        This command corresponds to vagrant box add <name> <URL>. As a result, the specified base box is downloaded to your machine.

      • To remove a base box, select it in the list and click the Remove button delete. The base box and the nested files are physically deleted from the disk. This command corresponds to vagrant box remove <name>.
Initializing the VaqrantFile

A VagrantFile is a configuration file that defines the instance (virtual machine) you need. The file contains the virtual IP address, port mappings, and the memory size to assign. The file can specify which folders are shared and which third-party software should be installed. According to the VagrantFile your instance (virtual machine) is configured, provisioned against the relevant Vagrant base box, and deployed on your computer. A VagrantFile is created through the vagrant init command.

You can initialize the VagrantFile in any folder, just keep in mind that this folder should be specified as the instance folder on the Vagrant page of the Settings dialog box. Otherwise WebStorm will be unable to find the relevant VagrantFile during the instance (virtual machine) creation.

To initialize the VagrantFile, do one of the following:

  • To have the VagrantFile created in the project root, choose Tools | Vagrant | Init on Project Root on the main menu and select the target project root from the pop-up list that opens. The output of the init command is displayed in the Run tool window.
  • To have the VagrantFile created in a specific folder, launch the embedded Terminal by choosing Tools | Open Terminal on the main menu, and then type the following commands at the prompt:
    cd <directory to initialize the VagrantFile in>
    vagrant init <base box name> <base box url>
                        

Once the VagrantFile initialization is successfully completed, you are ready to import the base box, provision and deploy it according to the VagrantFile, thus creating your own instance (virtual machine).

Creating and launching an instance (virtual machine)

Creating an instance (virtual machine) means importing and provisioning a base box according to the VagrantFile located in the instance folder.

To create an instance (virtual machine), do one of the following:

  • To have the instance created in the project root, choose Tools | Vagrant | Up.
  • Launch the embedded Terminal by choosing Tools | Open Terminal on the main menu, and then type the following commands at the prompt:
    cd <instance folder>
    vagrant up
                        
Stopping, suspending, resuming, reloading, and destroying an instance (virtual machine)
  • If you have made some changes to the VagrantFile and want a running virtual machine updated in accordance to them, choose Tools | Vagrant | Reload on the main menu or run the following command in the embedded Terminal:
    vagrant reload
                        
    For details, see http://docs.vagrantup.com/v2/cli/reload.html.
  • To temporary stop the operating system on a running virtual machine (guest machine) and save the exact state of the environment as it is at this moment so it can be resumed exactly from this point, choose Tools | Vagrant | Suspend on the main menu or run the following command in the embedded Terminal:
    vagrant suspend
                        
    For details, see http://docs.vagrantup.com/v2/cli/suspend.html.
  • To resume a previously suspended operating system on a virtual machine (guest machine) and have it run from the state saved at the suspension moment, choose Tools | Vagrant | Resume on the main menu or run the following command in the embedded Terminal:
    vagrant resume
                        
    For details, see http://docs.vagrantup.com/v2/cli/resume.html.
  • To shut down the operating system on a virtual machine (guest machine), choose Tools | Vagrant | Halt on the main menu or run the following command in the embedded Terminal:
    vagrant halt
                        
    For details, see http://docs.vagrantup.com/v2/cli/halt.html.
  • To shut down the operating system on a virtual machine (guest machine), stop the virtual machine itself, and remove the resources provisioned on it during the creation (vagrant up), choose Tools | Vagrant | Destroy on the main menu or run the following command in the embedded Terminal:
    vagrant destroy
                        
    For details, see http://docs.vagrantup.com/v2/cli/destroy.html.

See Also

Procedures:

Reference:

External Links:

Web Resources: