phpStorm+Xdebug+Chrome local debugging

PhpStorm local breakpoint debugging

1. Environment construction

Note: The following is the Windows+Apache environment

1. First check whether Xdebug is installed locally

Steps:
(1) Create a new PHP file in phpstorm, write phpinfo(), and run it. The interface shown in Figure 1-1 appears.
1-1

(2) Search Xdebug in the interface to see if the interface shown in 1-2 below appears. If not installed, continue with the steps below.
1-2

2. Install Xdebug

(1) Open the URL: http://xdebug.org/wizard.php, and copy all the information shown in Figure 1-1 into the box on the page. Get the interface shown in Figure 1-3
1-3

Xdebug-related information is shown in Figure 1-4:

1-4

(2)点击“download”进入Xdebug下载界面,下载相应的Xdebug版本;
(3)将下载好的.dll文件放入本地PHP环境的ext目录下;
(4)重启本地Apache服务;
重启服务成功后,在php.ini文件最后,会有XDEBUG EXTENSION的信息,我们
需要添加配置如下:
zend_extension的值根据自己的本地环境填写
zend_extension =“c:/wamp64/bin/php/php5.6.31/ext/php_xdebug-2.5.5-5.6-vc11-x86_64.dll”
xdebug.idekey=PHPSTORM
xdebug.remote_enable = On
xdebug.remote_host=localhost
xdebug.remote_port默认值为9000,这里需要跟phpstorm配置一致
xdebug.remote_port=8083
xdebug.remote_handler=dbgp
xdebug.auto_trace = On
(5)配置phpStorm,其中的Debug port确保不被其他应用占用,当程序无法进入断点时,可以考虑是否有其他应用占用了你本地的9000端口。
1-5

(6) Install Xdebug extension for Chrome browser
Download Xdebug (http://www.downza.cn/soft/211550.html) from Baidu, enter the browser extension program interface, and drag the downloaded program directly into the extension program interface:
1-6

Open the "Options" interface and set the IDE Key to PhpStorm.
1-7

After the setting is complete, a crawler-like icon will appear in the upper right corner of the browser (if the icon does not appear in time, please restart the browser and wait patiently for a while), as shown below:
1-8

two. breakpoint debugging

1. Open the project in the browser, and open the crawler icon in the upper right corner
1-9

2. Open the code to be debugged in the phpStorm editor
1-10

3. Refresh the page you have open in your browser again, and look at your phpstorm editor. The red circle of the breakpoint on the left turns into a tick in the circle, which means you have entered the breakpoint. As shown below

1-11
1-12

4. From the place 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 the function; press F8 to go down line by line in the current code page, and it will not jump when it encounters a function. These two functions are the most practical and key functions of breakpoint debugging.
5. When you want to jump directly from a breakpoint to another line breakpoint, you can enter the breakpoint, click the breakpoint where you want to break in another line, and then press F9 or click the green button in the lower border, as shown in the figure below.
1-13

Guess you like

Origin blog.csdn.net/yuwenwenwenwenyu/article/details/112325499