Configuring debugging in a DevVM below version 91
Edit on GitHubThis article describes how to configure debugging in a development environment for VM below version 91.
Installing the Xdebug module
To install the Xdebug module:
- Install Xdebug:
sudo -i apt-get install php5-xdebug
Enabling Xdebug
-
Make sure that Xdebug is enabled in your php.ini file
-
Enable Xdebug by updating
/etc/php5/mods-available/xdebug.ini
with the following:
xdebug.remote_enable=1
xdebug.remote_host=10.10.0.1
# This is needed to prevent max recursion exeception when Twig templates are very complicated
xdebug.max_nesting_level=1000
- Export Xdebug configuration:
export XDEBUG_CONFIG='idekey=PHPSTORM'
- Restart PHP:
sudo /etc/init.d/php5-fpm restart
If the restart is successful, you should get the following message: [ ok ] Restarting php5-fpm (via systemctl): php5-fpm.service
.
Configuring servers
Define servers in PhpStorm:
- In PhpStorm, go to Preferences > Languages & Frameworks > PHP > Servers.
- Add a new server:
- Select +.
- For Name, enter zed.mysprykershop.com.
- For Host, enter zed.mysprykershop.com.
- Select Use path mappings.
- Set Absolute path on server to
/data/shop/development/current
.
- For Yves, add another server. Copy the settings from the previous step, but, for Name and Host, enter.
Configuring debugger
-
In PhpStorm, go to Preferences > Languages & Frameworks > PHP > Debug.
-
In the External connections section, for Max. simultaneous connections, select 2.
Now you can debug Zed through a connection from Yves.
Debugging
To debug with PhpStorm:
-
Go to Run > Edit Configurations….
-
Add a PHP Remote Debug:
- Select +.
- Enter a Name.
- For Servers, enter zed.mysprykershop.com.
- For Ide Key(session id), enter PHPSTORM.
-
Select Listen for PHP Debug Connections
.
-
Select Debug
. You should get the message: “Waiting for incoming connection with IDE key ‘PHPSTORM’”.
Debugging console commands
To trigger Xdebug in CLI, prepend environment variables to commands as follows.
XDEBUG_CONFIG="remote_host=10.10.0.1" PHP_IDE_CONFIG="serverName=zed.mysprykershop.com" vendor/bin/console <command>
Configuring a Google Chrome helper for Xdebug
As a Chrome user, you can optionally configure the Xdebug helper extension as follows:
- Add Xdebug helper to the browser.
- In the extension settings, for IDE Key, select PhpStorm.
Now you can manage debugging sessions in the browser toolbar.
Configuring browser bookmarklets for Xdebug
To manage debugging sessions directly in a browser, configure browser bookmarklets as follows:
- Generate helper bookmarklets.
- Bookmark the generated links.
As a Chrome user, you can install the “Xdebug helper” extension. Under options set the IDE Key to “PhpStorm”. Everybody else can then generate bookmarklets with IDE key set to “PhpStorm” (Debugger bookmarklets generator for PhpStorm).
Now you can manage debugging sessions using the bookmarks you’ve created.
Thank you!
For submitting the form