Debugging Tools and Configuration¶
Complete guide for debugging WordPress and PHP applications using Laravel Herd.
Table of Contents¶
WordPress Debugging Plugins¶
Essential plugins for WordPress development and debugging:
- User Switching - Instantly switch between user accounts in WordPress for testing different user roles and permissions
- Query Monitor - Debug database queries, hooks, conditionals, HTTP requests, and more with detailed performance insights
- WP Crontrol - View and control WP-Cron jobs and schedules directly from the WordPress admin
- WP Console - Run WordPress and PHP code directly from your browser console for quick debugging
- WP Mail Logging - Log and view all emails sent through WordPress to debug email delivery issues
PHP Debug Configuration for VSCode¶
Prerequisites¶
- Laravel Herd installed
- Visual Studio Code installed
- Basic understanding of Xdebug
Step 1: Configure Xdebug in php.ini¶
Modify the php.ini file for your PHP version in ~/Library/Application Support/Herd/config/php/ folder.
Example for PHP 8.1 (~/Library/Application Support/Herd/config/php/php81.ini):
pcre.jit=0
output_buffering=4096
upload_max_filesize=200M
post_max_size=2000M
memory_limit=-1
auto_prepend_file=/Applications/Herd.app/Contents/Resources/valet/dump-loader.php
extension=/Applications/Herd.app/Contents/Resources/herd-ext/herd-81-arm64.so
zend_extension=/Applications/Herd.app/Contents/Resources/xdebug/xdebug-81-arm64.so
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.start_upon_error=yes
Note: Adjust the paths according to your PHP version (php81, php82, php83).
See the Laravel Herd Xdebug documentation for more details.
Step 2: Install PHP Debug Extension¶
Install the PHP Debug extension for VSCode.
Step 3: Create Launch Configuration¶
Create a .vscode/launch.json file in your workspace root:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/absolute/path/to/your/project": "${workspaceFolder}"
},
"log": true
}
]
}
Replace /absolute/path/to/your/project with your actual project path.
Example:
Step 4: Start Debugging¶
- Set breakpoints in your PHP code (click in the gutter next to line numbers)
- Press
F5or click Run > Start Debugging - VSCode will start listening for Xdebug connections
- Access your site in the browser
- VSCode should pause at your breakpoints
PHP Debug Configuration for PhpStorm¶
Prerequisites¶
- Laravel Herd installed
- PhpStorm installed
- Basic understanding of Xdebug
Step 1: Configure Xdebug in php.ini¶
Modify the php.ini file for your PHP version in ~/Library/Application Support/Herd/config/php/ folder.
Example for PHP 8.1 (~/Library/Application Support/Herd/config/php/php81.ini):
pcre.jit=0
output_buffering=4096
upload_max_filesize=200M
post_max_size=2000M
memory_limit=-1
auto_prepend_file=/Applications/Herd.app/Contents/Resources/valet/dump-loader.php
extension=/Applications/Herd.app/Contents/Resources/herd-ext/herd-81-arm64.so
zend_extension=/Applications/Herd.app/Contents/Resources/xdebug/xdebug-81-arm64.so
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.start_upon_error=yes
Note: Adjust the paths according to your PHP version (php81, php82, php83).
See the Laravel Herd Xdebug documentation for more details.
Step 2: Configure PHP Interpreter in PhpStorm¶
- Open PhpStorm > Settings (or Preferences on Mac)
- Navigate to PHP
- Click the ... button next to CLI Interpreter
- Click + to add a new interpreter
- Select Other Local...
- Set the PHP executable path:
- For PHP 8.1:
/Users/YOUR_USERNAME/Library/Application Support/Herd/bin/php81 - For PHP 8.2:
/Users/YOUR_USERNAME/Library/Application Support/Herd/bin/php82 - For PHP 8.3:
/Users/YOUR_USERNAME/Library/Application Support/Herd/bin/php83 - PhpStorm should automatically detect Xdebug
- Click OK to save
Step 3: Configure Debug Settings¶
- Go to PhpStorm > Settings > PHP > Debug
- Set the following:
- Xdebug port:
9003(default) - ✅ Check Can accept external connections
- ✅ Check Break at first line in PHP scripts (for initial testing, can disable later)
- ✅ Check Force break at first line when no path mapping specified
- ✅ Check Force break at first line when a script is outside the project
- Click OK
Step 4: Configure Server (for WordPress/Web Projects)¶
- Go to PhpStorm > Settings > PHP > Servers
- Click + to add a new server
- Configure:
- Name: Your project name (e.g.,
my-project.test) - Host: Your Herd domain (e.g.,
my-project.test) - Port:
80(or443for HTTPS) - Debugger:
Xdebug - ✅ Check Use path mappings
- Map your project root to the absolute server path:
- Local path:
/Users/YOUR_USERNAME/Herd/my-project - Absolute path on server:
/Users/YOUR_USERNAME/Herd/my-project
- Local path:
- Click OK
Step 5: Create Debug Configuration¶
- Click Run > Edit Configurations...
- Click + and select PHP Web Page
- Configure:
- Name: Debug My Project
- Server: Select the server you created in Step 4
- Start URL:
/(or your starting page) - Click OK
Step 6: Start Debugging¶
- Set breakpoints in your PHP code (click in the gutter next to line numbers)
- Click the Listen for PHP Debug Connections button (phone icon) in the toolbar
- Start debugging:
- Option A: Click Run > Debug 'Debug My Project'
- Option B: Install the Xdebug helper browser extension and enable debugging in your browser
- Access your site in the browser
- PhpStorm should pause at your breakpoints
Troubleshooting¶
Xdebug Not Detected¶
- Verify Xdebug is installed: Run
php -vin terminal (should show "with Xdebug") - Restart Herd after modifying php.ini
- Restart PhpStorm
Breakpoints Not Working¶
- Ensure the "Listen for PHP Debug Connections" icon is active (green)
- Check that port 9003 is not blocked by firewall
- Verify path mappings in Server configuration
- Check PhpStorm's Event Log for Xdebug connection messages
Path Mapping Issues¶
- Make sure local path exactly matches your project directory
- Absolute path should be the same for Herd local development
- Check for case-sensitivity in paths
Useful PhpStorm Shortcuts¶
| Action | Mac | Windows/Linux |
|---|---|---|
| Set/Remove Breakpoint | Cmd + F8 |
Ctrl + F8 |
| Resume Program | Cmd + Option + R |
F9 |
| Step Over | F8 |
F8 |
| Step Into | F7 |
F7 |
| Step Out | Shift + F8 |
Shift + F8 |
| Evaluate Expression | Option + F8 |
Alt + F8 |
Additional Resources¶
Documentation¶
- Laravel Herd Documentation - Official Herd documentation
- Xdebug Documentation - Complete Xdebug reference
IDE Guides¶
- VSCode PHP Debug Guide - VSCode extension documentation
- PhpStorm Xdebug Guide - Official PhpStorm debugging guide
Browser Extensions¶
- Xdebug Helper for Chrome - Enable/disable Xdebug from browser
- Xdebug Helper for Firefox - Firefox version
WordPress Debugging¶
- WordPress Debugging - Official WordPress debugging guide
- Query Monitor Documentation - Advanced WordPress debugging