Installing and Configuring Xdebug with PhpStorm for PHP Debugging
This guide walks through downloading the Xdebug extension, adding the required php.ini settings, configuring PhpStorm and Chrome helper extensions, using the debugging toolbar, and troubleshooting common issues to enable effective PHP breakpoint debugging.
First, download the Xdebug extension from the official site (https://xdebug.org/download) and choose the non‑thread‑safe (NTS) version that matches your PHP version.
Next, add the following configuration to your php.ini file, adjusting the paths to where you placed the DLL:
[xdebug]
zend_extension="D:\Server\PHP\ext\xdebug.dll"
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir="D:\Server\PHP\xdebug"
xdebug.trace_output_dir="D:\Server\PHP\xdebug"
xdebug.profiler_output_name="xdebug.cache.%t-%s"
xdebug.profiler_append=0
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"
xdebug.idekey=PHPSTORMAfter saving the file, restart your web server and verify the extension is loaded by visiting a phpinfo() page.
Configure PhpStorm for Xdebug:
Set the PHP CLI interpreter path.
Specify the Xdebug port (default 9001).
Enter the IDE key (PHPSTORM), host (localhost), and port.
Create a new server entry with a name matching your project.
Install the Chrome "PhpStorm Helper" extension (download from https://www.crx4chrome.com/crx/768/) and the accompanying debug plugin, then drag the downloaded .crx files into Chrome to install.
In Chrome, right‑click the debug icon, set the same IDE key, and enable the extension.
During a debugging session, the PhpStorm toolbar provides useful actions:
Restart request : clears all variables and starts a fresh request (similar to refreshing the page).
Step over : executes the current line and pauses at the next breakpoint.
Step into / Force step into : enters the called function, method, included file, or instantiated class.
Step out : exits the current function/method and returns to the caller.
Stop debugging : ends the debugging session.
Variables pane : shows global and local variables at the current breakpoint.
Navigate to source : jumps to the file and line where the breakpoint is set.
If Xdebug does not start, check the following common causes:
Incorrect zend_extension path or mismatched slashes.
Version mismatch between PHP and the Xdebug DLL (e.g., PHP 7.2 with a 7.1 build).
Architecture mismatch (32‑bit vs 64‑bit) between PHP and the Xdebug binary.
Using a TS build of Xdebug with an NTS PHP installation, or vice‑versa.
Addressing these issues and following the configuration steps will enable full breakpoint debugging of PHP applications in PhpStorm.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.