Phpstorm+xdebug Breakpoints Debugging Php method

Source: Internet
Author: User
This article mainly introduces the Phpstorm+xdebug breakpoint debugging Php method, this tutorial will be configured xdebug extension for breakpoint debugging, in order to improve the development efficiency of everyone, interested in small partners can refer to

Why Debug with Breakpoints

You may think that using var_dump and echo can also debug Ah, why also install Xdebug breakpoint debugging it?

That's true. But Var_dump and Echo write the code after the deletion, and clearly know where to hit, if found not run to the point of the place, but also to modify the code to run again. While debugging breakpoints, you can dynamically break points during debugging, view the values of the current variables row by line, and even temporarily modify the values of variables, more convenient. We recommend that you use Xdebug breakpoint debugging.

Installing Xdebug

PECL Install Xdebug

If the following version is PHP7, the version number needs to be added:

PECL Install xdebug-2.5.5

Pecl If you are prompted not to find the extension, use source code compilation. For example:

wget http://pecl.php.net/get/xdebug-2.5.5.tgz \  && tar xzf xdebug-2.5.5.tgz && CD xdebug-2.5.5/\< c5/>&& phpize \  &&./configure \  && make && make install

Note: php5.6 can only use version xdebug of 2.5 and below.

After installation, it needs to be configured in php.ini:

[Xdebug]zend_extension=xdebug.soxdebug.enable=1xdebug.remote_enable=1; If this is turned on, the following xdebug.remote_host parameters will be ignored; Xdebug.remote_connect_back=1 automatic start-up without xdebug_session_start=1xdebug.remote_autostart=1; host ipxdebug.remote_host= 192.168.36.101 XDEBUG.REMOTE_PORT=19001XDEBUG.REMOTE_HANDLER=DBGP

It is important to note that:

1, is zend_extension, not extension;

2, xdebug.remote_autostart Open, you do not have to manually add in the request URL XDEBUG_SESSION_START=1 , as long as the Phpstorm open breakpoint debugging is OK. Very convenient;

3, the remote_host configuration is installed with Phpstorm machine, this need to pay attention to. If the machine installed by PHP and the Phpstorm machine is the same machine, then the address 127.0.0.1 can be written.

If you are using a Docker environment, remote_host write the host's IP.

4, the xdebug.remote_port port I write is 19001 , then phpstorm also need to modify.

After the configuration is complete, you need to restart PHP-FPM.

Configure Phpstorm

Configuration is also simple, configure the port to:

Next, you can debug the breakpoint. Turn on monitoring:


The request is automatically captured when the URL is requested.

Attention:

1, do not open the monitoring of multiple projects at the same time;

2, when listening to remote code, if the host and the code is in the same directory structure, will be directly monitored success. Otherwise, you are prompted to set up a code mapping relationship. You can also set it manually:

This is because the host is Windows, the code is in Linux, the directory is inconsistent, and the mapping is done. Otherwise the breakpoint will fail.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.