Home >Backend Development >PHP Tutorial >Configure the Xdebug debugging environment for PHPStorm

Configure the Xdebug debugging environment for PHPStorm

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-08-08 09:25:321076browse

My environment

  • Operating system: 64-bit win7 Ultimate Service Pack 1
  • PHP version: php-5.6.7-Win32-VC11-x64
  • Apache version: httpd-2.4.12-win64-VC11
  • PHPStorm version: PhpStorm 8.0.3

Download Xdebug

Xdebug official website: http://xdebug.org/
The latest version of Xdebug is 2.3.2. In order to match my PHP environment, I downloaded the php_xdebug-2.3.2-5.6-vc11-x86_64.dll library. Download address: http://xdebug.org/files/php_xdebug- 2.3.2-5.6-vc11-x86_64.dll

Configure php.ini

and copy the downloaded php_xdebug-2.3.2-5.6-vc11-x86_64.dll library to the %PHP_HOME%/ext directory, and then open php.ini Add the following configuration to the file:

<code>[XDebug]
zend_extension=php_xdebug-<span>2.3</span><span>.2</span>-<span>5.6</span>-vc11-x86_64<span>.dll</span>
xdebug<span>.idekey</span>=<span>"PHPSTORM"</span>
xdebug<span>.remote</span>_handler = <span>"dbgp"</span>
xdebug<span>.remote</span>_mode = <span>"req"</span>
xdebug<span>.remote</span>_host=<span>127.0</span><span>.0</span><span>.1</span>
xdebug<span>.remote</span>_enable=on
xdebug<span>.remote</span>_port = <span>9000</span>
xdebug<span>.remote</span>_autostart = no</code>

The location of the dll library downloaded above is not fixed, as long as it is accurately specified in the php.ini configuration file, that is, the zend_extension configuration item points to the dll library file.

PHPStorm settings

Deployment settings

Create a project deployment entry. Since I am debugging a local project, the setting type here is "Local or mounted folder"; then specify the project path and set the URL root of the Web service

Server settings

Go to Languages ​​& Frameworks > PHP > Servers configuration, add a server configuration, customize the Name (I use localhost here), Host is localhost (local debugging), Port is set to 80, Debugger just select Xdebug.

After the configuration is completed, you can verify whether the configuration is successful. Click the "Validate remote environment" button in this configuration interface, and select the deployment project set in the "Deployment Settings" step in the pop-up dialog box (here is sycms) , if no error message appears in the Information area of ​​the dialog box, it means that the Servers settings are correct.

Debug settings

Find Languages ​​& Frameworks > PHP > Debug configuration and set the Debug port to 9000 (consistent with the port setting in the php.ini configuration file).

Expand Debug and set DBGp as shown in the figure below:

The IDE Key is the value of the xdebug.idekey configuration item in the php.ini file.

Browser settings

Install the Xdebug plug-in for the browser. I chose the Firefox browser and The easiest Xdebug Firefox plug-in. After installation, as shown below, fill in the IDEKey into the red box in the picture below:

Debug with Xdebug

Enable the Xdebug plugin in your browser
Then open the "Run/Debug Configuration" configuration, create a new "PHP Web Application" startup item, specify the correct Server and Start URL and save it, as shown below:

Open Xdebug monitoring in PHPStorm (in the startup toolbar The "Start Listening for PHP Debug Connections" button that looks like a phone receiver).
Set a breakpoint, and then access the address corresponding to the "Start URL" in the "Run/Debug Configuration" configuration in the browser to successfully connect to PHPStorm, as shown below:

FAQ

First time When running Xdebug debugging, PHPStorm reported the following error:

<code>Cannot accept external Xdebug connection: Cannot evaluate expression'isset($_SERVER['PHP_IDE_CONFIG'])';
</code>

The reason is that the dll file configuration in the php.ini file is

<code>extension=php_xdebug-2.3.2-5.6-vc11-x86_64.dll
</code>

Change it to zend_extension and restart Apache, as shown below:

<code>zend_extension=php_xdebug-2.3.2-5.6-vc11-x86_64.dll
</code>

Reference materials

-http://blog.csdn.net/dc_726/article/details/9905517
-http://www.chenxuanyi.cn/xampp-phpstorm-xdebug.html

The above introduces how to configure the Xdebug debugging environment for PHPStorm, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn