Setting up test suite with PhpStorm and Laravel Homestead

PhpStorm is awesome but setting it up to run the test suite with Homestead is annoying and something I always forget. It’s something you usually set and forget. So for future reference here’s how it’s done. Future me enjoy. 🙂

1 – With Homestead running navigate to PhpStorm settings area (cmd + ,) and search for ‘Deployment’
2 – Click the + symbol, give it a name and choose SFTP.
3 – In the ‘connection’ tab enter:

SFTP host: yourdomain.test
Port: 22
User name: vagrant
Auth type: Password
Password: vagrant

4 – Test the connection and make sure its connecting and then click on the the ‘mappings’ tab.
5 – Fill out local path to your project (should be auto filled)
6 – Fill out the server path e.g /home/vagrant/projectfolder
7 – Now search for ‘PHP’ from the main settings window and navigate to this settings area
8 – Select PHP 7.0 as the version if not selected, then click the ‘…’ to select an interpreter.
9 – In the next window click the ‘+’ and add a remote Interpreter and click ok.
10 – That should be it as far as setting up the vagrant/homestead box. Now need to setup so that PHP unit will run from within PhpStorm. In the settings search for ‘PHPUnit’ then click on ‘Test Frameworks’
11 – Click on the ‘+’ and then select the option with ‘by remote interpreter’ and then choose the Vagrant interpreter.
12 – Select ‘use custom autoloader’ and ensure the paths to script and xml file are correct. They should be something like: ‘/home/vagrant/laravelexample/vendor/autoload.php’ and ‘/home/vagrant/laravelexample/phpunit.xml’
13. Confirm all is working by running any test in PHP Storm.