Occasionally making phpunit work with PhpStorm and homestead

When using homestead on vagrant I find that I need to use ssh/sftp setup for the server and interpreter for it to get the path mappings correct.

Settings I configure

"Build, Exection, Deployment" -> "Deployment"
Add an entry for the server and set its "Type" to be "SFTP".
In the "Connection" tab, set the details according to the information obtained by running "vagrant ssh-config".
Set the "Auth type" to "Key pair" and set the "Private key file" to be the location of the IdentityFile from the ssh-config.

In the "Mappings" tab, make sure that the deployment path remote server location matches the local path.

Set up the PHP interpreter by going to "PHP" and adding a remote Interpreter. Set the remote to be based on the "Deployment configuration", saves you setting up all the SSH information again.

In "PHP" -> "PHPUnit" add a "Remote Interpreter" and pick the one you set up.
Set the "custom autoloader" to be the location of your vendor/autoload.php and optionally set the location of you phpunit.xml in the "Test Runner" -> "Default configuration file"

Make sure xdebug is configured by doing similar to "sudo nano /etc/php/7.0/fpm/conf.d/20-xdebug.ini

xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.scream=0 
xdebug.cli_color=1
xdebug.show_local_vars=1

Restart the service for php by doing "sudo service php7.0-fpm restart" or similar.

Comments

Popular posts from this blog

Enabling SNMP on an ASUS RT-N66U

Making Microsoft Dataverse OData queries using Postman

Debugging multiple PHP projects with VS Code and Laragon