When you apply this options, a small window will appear telling you that PHPStorm added your dependencies to the Include Path. Its important that the checkbox Add packages as libraries is selected.
This should be the path on your local machine. Add the Path to your composer.json there. To configure this go to Settings -> Languages & Frameworks -> PHP -> Composer. Unfortunately I havent found a way to use the composer on your vagrant box, but just to tell about the packages, that is what we actually need, we dont have to specify it. It will learn the path to the phpunit.php from that. When you manage your dependencies via composer, especially as I do with phpunit for this demo, you should tell PHPtorm about your composer.json. Step Four – Configure composer (optional) The path mapping should map from your project root directory to the project root directory on the vagrant box. Enter your project URL and select a path mapping. Go to Settings -> Languages and Frameworks -> PHP -> Servers. In order to be able to debug our application we have to provide a PHP server configuration. In the dialog you can use the Radio-Button Deployment Configuration and select the one you just created. Now go again to the small + in the upper left corner of the window and select Remote. Go to Settings -> Languages & Frameworks -> PHP and click on the … next to the Interpreter dropdown. The next step i to add the PHP Interpreter for your project.
Step Two – Create a remote PHP interpreter In the Mappings tab you should add the Deployment path on your server. vagrant.d in your home directory or in the latest versions of vagrant you can find it in the. In the Connection details you can use the private key vagrant provides. You will have to enter the Connection details and the Mappings. Use the small + symbol to and add a Server with type SFTP. Go to Settings -> Build, Execution, Deployment -> Deployment. The first thing we want to do is to create the this deployment configuration as we can use it later on when we have to select the PHP-Interpreter. Step One – Create a SFTP-Deployment configuration Be aware that a good description of your environment is necessary in order to understand problems and finding solutions. If it doesnt work for you and you get stuck please dont hesitate to ask about that as comments in this article, so maybe I can help somewhere. DisclaimerĪll the shown options are working for me, but of course they can vary from project to project. To show this sample configuration and to test if everything really works, I created a new project with the symfony demo application and the wasted project that provides a very nice way to setup a vagrant box for symfony2 (and other) projects. With a SFTP-Deployment configuration this will happen instantly and without drawbacks. This I can not recommend as it will create a pop-up for every testrun you execute and will take about 5 seconds until the tests first launch. Once you have the base configuration it should be easy to figure that out on your own :)Īnother reason why I write this article is that I have seen the usage of the Vagrant configuration option for the remote interpreter. With the latest version of PHPStorm (at this time 9) you can even let other functionality like PHPMD or PHPCS run on your VM, but I wont go into details with them.
So the main goal of this article is to show you how to configure PHPStorm that it is able to run your test-suite on the virtual machine with all the functionalities that you have when running them locally. This configuration is not only valid for a VM managed with vagrant, but with any other as well.
Thats why I want to show you a sample configuration via the SFTP-Deployment + Remote Interpreter capabilities of PHPStorm, where you won’t even recognize anymore that you are not working on your host system. Though it was surprising to me, that I have hardly ever seen someone taking the time to investigate how to configure PHPStorm properly, so that it plays nice with the virtual machine in use. At Mayflower we usually use virtual machines managed with vagrant for our development environments.