Setting Up Better PHPUnit to Run Inside a Vagrant VM
For the last several months, I’ve been using Visual Studio Code for all my PHP projects. I started using Better PHPUnit to run my unit tests because it has a quick keyboard shortcut to run a specific unit test from inside Code. I just set Better PHPUnit up on a new computer I forgot a couple of hoops I had to jump through in order to get it to run inside my Vagrant VM. This post is documentation so I won’t forget and that will hopefully help someone else.
The first step is to determine the name of the SSH user that Vagrant uses to connect through SSH. This is done using the vagrant ssh-config
command from your host computer.
This is a “duh” statement but the “User” line is what we’re looking for.
The next item we need to know is what IP address our VM is using. This can be found in our Vagrant file in a line that looks like the one below.
Next we need to open our settings.json file inside Visual Studio Code and add the following lines:
Now this might work but you’ll be prompted for a password each time which is super annoying. To make this process easier I got the value of my public key on my host computer:
And then I append it to the authorized_keys in my VM:
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows