PhpStorm Configuration

Enable WordPress Integration

Go to Settings → PHP → Frameworks → WordPress, click enable and 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 (View → Tool Windows → Database), click the plus symbol, select Data Source → MariaDB. Call the database Pressbooks Test, and set the following values:

In the General tab (Tip: Credentials are comming from the /site/.env file):

Provide the user & password for a user who has database access to your local installation.

In the SSH/SSL tab:

Configure Remote PHP Interpreter

Open Settings → PHP and find the CLI Interpreter option. Click the three dots [...], click the plus symbol, select "From Docker, Vagrant, VM, WSL, Remote" and set "Vagrant Instance File" to your Trellis directory.

PHP Interpreter settings step 1 PHP Interpreter settings step 2 PHP Interpreter completed

XDebug

Update to the latest PHPStorm and get the Xdebug Helper Chrome plugin.

Go to Settings → PHP > Servers, create a new server named pressbooks.test and map:

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, and reload the website in Chrome:

Xdebug In Action

Configure Remote PHPUnit

Settings → PHP → Test Frameworks, 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/pressbooks.test/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-running bin/install-wp-tests.sh