Speaking of PHP code debugging, for experienced phper, through the Echo, Print_r, Var_dump function, or PHP development tools Zend Studio, EditPlus can solve most of the problems, but for the introduction of PHP to learn the children's shoes have a certain degree of difficulty, And just through these PHP debugging means, it is difficult to accurately detect PHP performance problems, Xdebug is a very useful PHP debugging tool.
Xdebug, as a PHP debugging tool, provides rich debugging functions, and can also configure Xdebug installation as Zend Studio, EditPlus debug Third-party plug-ins for PHP, and by turning on automatic tracking (auto_trace) and analyzer functions, You can visually see the PHP source code performance data in order to optimize the PHP code. Share with you today the basics of PHP Debugging Tools Xdebug installation and configuration.
The Xdebug installation configuration in PHP involves modifications to the php.ini configuration file.
Xdebug Installation Tutorial
Download Xdebug
First we need to download xdebug, be sure to install the PHP version, choose the appropriate xdebug version, because I am in the Windows environment installed PHP (refer to Windows 7 installation configuration Php+apache+mysql Environment Tutorial), So choose to download the Windows version of Xdebug2.1.0 (5.3 VC6), download the Xdebug file for Php_ Xdebug-2.1.0-5.3-vc6.dll, this is because the Xdebug is installed as a PHP module in the form of being configured and used.
xdebug Installation Tips : If you do not know the PHP version installed, you can see through the phpinfo () function, and Xdebug also provides Phpinfo output information analysis tool to help you analyze how to install Xdebug, As long as the Phpinfo output information copy submitted, Address: Xdebug phpinfo Information Analysis Address
Install Xdebug
Copy the downloaded Php_xdebug-2.1.0-5.3-vc6.dll to the ext directory in the PHP installation directory, where the C:\php\ext,ext directory is dedicated to storing PHP extension library DLL files.
Configure PHP.ini
The final step in installing the Xdebug is to configure the php.ini file, open the php.ini configuration file in the C:\php directory, and add at the end
1 2
|
[Xdebug] zend_extension= "C:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll" |
Finally reboot the Apache server, through the Phpinfo () function, you can see
PHP Xdebug configuration information
xdebug configuration hint : PHP5.3 Previous version configuration Xdebug use Zend_extension_ts, for PHP5.3 above version, use Zend_extension.
XDEBUG not LOADED as ZEND why extension information appears
The reason for the Xdebug not LOADED as ZEND extension is that when you install Xdebug, because we copy the Xdebug DLL file to the Php\ext directory, it is easy to load xdebug in the form of a PHP extension library, Added in the php.ini file
1
|
Extension=php_xdebug-2.1.0-5.3-vc6.dll |
This is the wrong Xdebug installation method and must be loaded in Zend mode.
Now that the basic installation tutorial for PHP Xdebug is over, we need to make some basic configurations for xdebug.
Xdebug Configuration Tutorial
After the installation of Xdebug, we also need to do the basic configuration of Xdebug, the default xdebug PHP function automatic tracking (auto_trace) function, analyzer function is not turned on, as the need to debug PHP code, some xdebug configuration option is best to open.
Before that we needed to create a directory of Xdebug automatic tracking and parser output files, making sure that the directory was readable and writable, where I created Xdebug\trace and Xdebug\profiler directories under D:\PHPWeb\.
Finally, in the php.ini configuration file to complete the Xdebug configuration work, find
1 2
|
[Xdebug] zend_extension= "C:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll" |
Add Xdebug configuration information after this
1 2 3 4 5 6
|
Xdebug.auto_trace=1 Xdebug.collect_params=1 Xdebug.collect_return=1 Xdebug.trace_output_dir= "D:/phpweb/xdebug/trace" Xdebug.profiler_enable=1 Xdebug.profiler_output_dir= "D:/phpweb/xdebug/profiler" |
Finally, save the php.ini and restart the Aapche server.
Xdebug Partial configuration options description
Xdebug.auto_trace = 1
Whether to allow Xdebug trace function calls, trace information stored as files, default value 0
Collect_params = 1
Whether to allow Xdebug trace function parameters, the default value is 0
Xdebug.collect_return = 1
Allow the Xdebug trace function to return a value with a default value of 0
xdebug.profiler_enable = 1
Open the Xdebug Performance Analyzer, stored as a file, which cannot be configured with the Ini_set () function, with a default value of 0
Xdebug.profiler_output_dir
Where the profiling file is stored, the default is/tmp
Xdebug.profiler_output_name
The naming convention for profiling files, the default value is cachegrind.out.%p
Xdebug.trace_output_dir
function call trace information output file directory, default is/tmp
Xdebug.trace_output_name
function call trace information output file naming rules, default to Trace.%c
Special Note : Xdebug's Trace and Profiler output file name rules can be changed, such as the file name for the specific tracking of PHP execution file name, process ID, random number, very convenient, more xdebug configuration options to explain, Please refer to the official website's xdebug configuration option description.
The PHP Debugging tool xdebug Tutorial Xdebug installation and configuration is finished, and will be introduced in the future Xdebug How to configure the use of Zend Studio and EditPlus.
Note : PHP Web Development Tutorials-leapsoul.cn Copyright, reproduced in the form of links to indicate the original source and this statement, thank you.