← Back to all posts
Code Auditing2 min read

Pitfalls When XDebug Fails to Work in phpStudy

Common reasons XDebug fails to work in phpStudy include incorrect paths, incompatible extension versions, and incomplete configuration, followed by the correct process for enabling it.

#Environment Setup
Read in Chinese→

1. Reasons Why Enabling XDebug Has No Effect

1. Incorrect path
The zend\_extension path in the php.ini file is incorrect, such as using the wrong slash direction or specifying the wrong path.

2. php_debug extension version mismatch

The 32-bit or 64-bit php_debug extension does not match the installed PHP version
For example, if PHP 7.2 is installed but the downloaded php_debug version is for PHP 7.1, debugging will fail to start.
Make sure the NTS/TS build of the downloaded php_debug extension matches the installed PHP build
In a typical integrated environment, **PHP的架构都是**32位的(x86)****,, while your computer is 64-bit (x64), 以PHP的环境架构为准. For example, my PHP installation was 32-bit and my computer was running 64-bit Windows 10. I downloaded the 64-bit extension directly from the Xdebug official website, which caused the extension to fail to load.
3. Incomplete configuration file
The required configuration is provided below.

2. Detailed Process for Enabling XDebug

The versions must match
1、Use the phpinfo function to view the PHP version information. Pay attention to the following:

![Insert image description here](/images/20191220140707338.png 2、Using the information in the red box above, go to https://xdebug.org/download.php and download the corresponding Xdebug extension
Note that on the official Xdebug website:
Builds without (TS) are non-thread-safe versions (NTS).
Builds without (TS) are non-thread-safe versions (NTS).
Builds without (TS) are non-thread-safe versions (NTS).
![Insert image description here](/images/20191220141048558.png 3、Add the following information to the php.ini file:```java [XDebug] zend_extension=“D:\phpStudy\PHPTutorial\php\php-7.2.1-nts\ext\此处为刚刚下载好的路径” ;是否允许Xdebug跟踪函数调用,跟踪信息以文件形式存储,默认值为0 xdebug.auto_trace=1 ;是否允许Xdebug跟踪函数参数,默认值为0 xdebug.collect_params=1 ;是否允许Xdebug跟踪函数返回值,默认值为0 xdebug.collect_return=1 ;函数调用跟踪信息输出文件目录,默认值为/tmp xdebug.trace_output_dir =“F:\PHP_xdebug” ;性能分析文件的存放位置,默认值为/tmp xdebug.profiler_output_dir =“F:\PHP_xdebug” ;打开xdebug的性能分析器,以文件形式存储,这项配置是不能以ini_set()函数配置的,默认值为0 xdebug.profiler_enable = 1 ;性能分析文件的命名规则,默认值为cachegrind.out.%p xdebug.profiler_output_name = “cachegrind.out.%t.%p” xdebug.remote_enable = 1 ;用于zend studio远程调试的应用层通信协议 xdebug.remote_handler = “dbgp” xdebug.idekey = PHPSTORM xdebug.remote_host = “127.0.0.1” xdebug.remote_port = 9000


Check phpinfo to confirm that XDebug has been enabled successfully.  
![在这里插入图片描述](/images/20191220141539211.png)