Home >Backend Development >PHP Tutorial >Detailed explanation of PHP debugging and performance analysis tool Xdebug
The following editor will bring you a detailed explanation of the PHP debugging and performance analysis tool Xdebug. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
During the program development process, the most commonly used debugging method is to print statements using echo, print_r(), var_dump(), printf(), etc. The execution efficiency of PHP scripts is usually the script execution time. The efficiency of database SQL is usually the database Query time, but this cannot truly locate and analyze the bottlenecks of script execution and database queries? In this regard, there is a PHP program debugger (ie a Debug tool) called Xdebug (www.xdebug.org), which can be used to track, debug and analyze the running status of PHP programs.
1. A brief introduction to the installation of this module on the windows platform:
1. Download the XDebug extension for PHP, URL: http://xdebug.org/ (This depends on the PHP version you are currently using);
2. Will download the module (php_xdebug-2.0.5-5.2. dll) into the ext directory of PHP installation;
3. Configure the php.ini file and add the following lines
**** ************************************
extension=php_xdebug-2.0.5-5.2. dll
[Xdebug]
xdebug.profiler_enable=on
xdebug.trace_output_dir="E:/Projects/xdebug" #Directory where Xdebug output data files are placed
xdebug.profiler_output_dir="E:/ Projects/xdebug"
********************************************** *************
4. Restart the Apache server. Finish! ! !
5. If xdebug is seen in the output content, it means the installation and configuration are successful.
6. Under the Windows platform, you can use the client (Windows): WinCacheGrind WinCacheGrind to open these files. The content can be displayed more intuitively:
## 2. A brief introduction using the Linux platform:
1. Compile and install XDebug under Linux
[root@localhost xdebug -2.0.5]# /usr/local/php/bin/phpize
[root@localhost xdebug-2.0.5]# ./configure --enable-xdebug --with-php-config=/usr/locar /php/bin/php-config
[root@localhost xdebug-2.0.5]# make
can copy the generated xdebug.so to the path directory pointed by extension_dir.
2. Configuration
vi /usr/local/php/lib/php.ini Modify php.ini, remove the PHP acceleration module, and add the following configuration information to support XDebug Extension#extension=vld.so //It is the module that outputs OPCODES
extension=xdebug.so
[Xdebug]
xdebug.profiler_enable=on
xdebug.trace_output_dir="/tmp/ xdebug"
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profile_output_name="script"
3. Restart the WEB server
[root@localhost xdebug-2.0.5]# service httpd restart OK!!!The Xdebug tool will write the tracked error information into the output data file in the form of a diary, which can be viewed in the file, but in order to be more intuitive, there is also a graphical interface tool to analyze the traced journal records. WinCacheGrind (wincachegrind.souceforge.net) This software can be installed directly. From the graphics window, the structure of the entire program, the number of times each function is called, and the execution time can be clearly seen. Very professional and convenient! ! !Summary: overall system performance.
phpstorm xdebugRealizing breakpoint debuggingphp
The above is the detailed content of Detailed explanation of PHP debugging and performance analysis tool Xdebug. For more information, please follow other related articles on the PHP Chinese website!