PhpStorm Configuration

Enable WordPress Integration

Go to Settings > Languages & Frameworks > PHP > WordPress, enable, set installation path to ~/Code/pressbooks-dev/site/web/wp:

WordPress integration

Npm

Right click on package.json, select “Show npm Scripts”:

npm Tasks

Databases

In the Database tool window, click the plus symbol, select Data Source > MySQL:

Databases

In the SSH/SSL tab:

  • Proxy host: pressbooks.dev (Port: 22)
  • Proxy user: vagrant
  • Auth type: Key pair (OpenSSH)
  • Private key file: ~/Code/pressbooks-dev/trellis/.vagrant/machines/default/virtualbox/private_key

In the General tab:

  • Host: 127.0.0.1 (Port: 3306)
  • Database: example_com_development
  • User: example_com
  • Password: example_dbpassword

In the General tab for the testing database (use the same config as above for SSH/SSL):

  • Host: 127.0.0.1 (Port: 3306)
  • Database: pressbooks_tests
  • User: pressbooks_test
  • Password:

Configure Remote PHP Interpreter

Settings > Languages & Frameworks > PHP > CLI Interpreter, click the three dots […], click the plus symbol, select “From Vagrant”, set “Vagrant Instance File” to the trellis directory.

PHP Interpreter

XDebug

Get the Xdebug Helper Chrome plugin.

Go to Settings > Languages & Frameworks > PHP > Servers, create a new server named pressbooks.dev and map:

  • pressbooks-dev/site to /srv/www/example.com/current
  • pressbooks-dev/trellis to /home/vagrant/trellis

Xdebug Setup

Enable Xdebug Helper in Chrome, set some break points in PhpStorm,enable the “Start Listening for PHP Debug Connections” telephone icon in PhpStorm, reload the website in Chrome:

Xdebug In Action

Configure Remote PHPUnit

Settings > Languages & Frameworks > PHP > PHPUnit, create a new configuration based on Remote Interpreter, set path to autoload and configuration to point to files on remote server:

PHPUnit

Click the three dots […] next to path mappings and set pressbooks-dev/site to /srv/www/example.com/current:

PHP Mappings

Create and run new test configurations with “Test scope: Defined in the configuration file”

PHPUnit Running

Troubleshooting: If you have restarted your VM you will see a PHP Fatal error: require_once(): Failed opening required '/tmp/wordpress-tests-lib/includes/functions.php' Fix by re-runing bin/install-wp-tests.sh (@see Unit Testing and Coding Standards)