Home >Development Tools >phpstorm >Detailed explanation of PhpStorm local breakpoint debugging method

Detailed explanation of PhpStorm local breakpoint debugging method

藏色散人
藏色散人forward
2020-12-17 16:21:194456browse

The following tutorial column will introduce you to the methods and steps of PhpStorm local breakpoint debugging. I hope it will be helpful to friends in need!

Detailed explanation of PhpStorm local breakpoint debugging methodForeword:

When debugging PHP code, print_r or var_dump is often used. Breakpoints, but when the project is more complex, this is very inefficient. Breakpoint debugging solves this problem very well. You may not be comfortable with breakpoint debugging at first, but once you get used to it, the more you use it, the more comfortable you will become.
Note: The following is in the windows7 apache environment

1. Breakpoint debugging php environment setup

1. Detect local Whether Xdebug is installed in the php environment

Output phpinfo() locally; search for Xdebug; as shown below



##If not installed, install it Operate Xdebug as follows:

Enter all the information in phpinfo(); into the box in the URL: http://xdebug.org/wizard.php to get the adapted xdebug version, as shown in the figure below The operation proceeds.



2. After installing Xdebug, configure the local php.ini. Add the configuration as follows. If you need to add other Xdebug configurations, you can view the xdebug configuration in phpinfo and add it yourself according to the situation.

[xdebug]
;zend_extension的值根据自己的本地环境填写
zend_extension = "D:/IdeMix442_jcp/php-5.5.27-Win32-VC11-x64/ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll"
xdebug.idekey=phpstorm
xdebug.remote_enable = On
xdebug.remote_host=localhost
;xdebug.remote_port默认值为9000,这里需要跟phpstorm配置一致,下面有说明
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.auto_trace = On

3. Then configure phpstorm, and ensure that the Debug port is not occupied by other applications. When the program cannot enter the breakpoint, you can consider whether other applications occupy your local 9000 port.


4. Install the Xdebug extension for your chrom browser

Xdebug download address: https://www.jb51. net/softs/544430.html


After downloading, unzip it, choose one of the versions, install it in your chrom browser (just drag it into the browser extension), I will test it myself The 360 ​​speed browser is also available. After the installation is complete, a crawler-like thing will appear in the upper right corner of the browser, as shown below.



##2. Start your breakpoint debugging

1. In your browser with the Xdebug extension installed, open a page of your local project. And turn on debug in the upper right corner of the browser, as shown below.


2. In your phpstorm editor, open the code you want to go through on the page in the browser, and operate as shown below.



3. Refresh the page you opened in the browser again, and then look at your phpstorm editor. The red circle at the breakpoint on the left changes to a check mark in the circle, which means you have entered the breakpoint. As shown below



3. Some simple operations for breakpoint debugging

1. View The values ​​of some variables before your breakpointDouble-click the variable you want to view, and the value will appear when the mouse stays on it. Or right-click after selecting it and select Add to Watch (the English version is add to watch), as shown below



## 2. From where your breakpoint starts, you can press F7, and the program will go down step by step. If it encounters a function, it will jump to that function; press F8 to go down line by line in the current code page. It will not jump when it encounters a function. These two functions are the most practical and key functions of breakpoint debugging.

3. When you want to jump directly from a breakpoint to a breakpoint on another line, you can enter the breakpoint, click on the breakpoint where you want to breakpoint on another line, and then press Press F9 or click the green button in the lower border, as shown below.

4. When you breakpoint in multiple places due to breakpoint debugging, and open multiple files, and want to check where you brokepointed, you can Press Ctrl Shift F8 to browse breakpoints


5. There are many tips for breakpoint debugging, which you can slowly discover and explore while using them.

The above is the detailed content of Detailed explanation of PhpStorm local breakpoint debugging method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete