PhpStorm local breakpoint debugging method steps

不言
Release: 2023-03-28 22:46:02
Original
2119 people have browsed it

This article mainly introduces the methods and steps of local breakpoint debugging of PhpStorm. It has certain reference value. Now I share it with everyone. Friends in need can refer to it.

When debugging PHP code, often Use print_r or var_dump to set breakpoints, but when the project is more complex, this is very inefficient. Breakpoint debugging solves this problem very well. This article mainly introduces the method of local breakpoint debugging in PhpStorm. Steps, interested friends can refer to

Preface:

When debugging PHP code, it is often print_r or Use var_dump to breakpoint, 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
Copy after login

3. Then configure phpstorm. The Debug port ensures that it is not occupied by other applications. When the program cannot enter the breakpoint, you can consider whether there are other The application occupies your local port 9000.


4. Install the Xdebug extension for your chrom browser


Xdebug download address: http://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 debugging1. 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 debugging1. View The values of some variables before your breakpoint


Double-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 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 during use.

Related recommendations:

PHP MariaDB database operation basic skills memo summary

##

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

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!