PHP Debugging Tools xdebug Assembly Configuration Tutorial

Source: Internet
Author: User
Tags php debugging tools php source code phpinfo
PHP Debugging Tools xdebug Installation Configuration Tutorial

Say 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 PHP beginners to learn the children's shoes have a certain degree of difficulty, and just through these PHP debugging means, it is difficult to pinpoint the PHP performance problem, Xdebug is a very useful PHP debugging tool .
Xdebug as a PHP debugging tool, provides a rich set of debugging functions, you can also configure the Xdebug installation as Zend Studio, EditPlus debugging PHP third-party plug-in, by turning on auto-tracking (auto_trace) and analyzer functions, You can visually see the PHP source code performance data in order to optimize the PHP code. Today we share the basics of PHP Debugging Tools Xdebug installation and configuration.

Xdebug Installation Tutorials

Download Xdebug?????? http://xdebug.org
 First we need to download xdebug, be sure to choose the appropriate version of Xdebug according to the version of PHP installed , if you do not know the version of PHP installed, you can see through the phpinfo () function, At the same time Xdebug also provides Phpinfo output information analysis tool to help you analyze how to install Xdebug, as long as the Phpinfo output information replication submitted, Address: Xdebug phpinfo Information Analysis Address
Installing Xdebug
Copy the downloaded Php_xdebug-2.1.0-5.3-vc6.dll to the ext directory in the PHP installation directory and the EXT directory is dedicated to the PHP extension library DLL file.

Configure PHP.ini
The last step in installing Xdebug is to configure the php.ini file and add it at the end

[xdebug]zend_extension= "C:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll"

Finally restart 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. ?

  Reason for XDEBUG not LOADED as ZEND extension information appears

The reason for the presence of Xdebug not LOADED as ZEND extension is that it is easy to load Xdebug as a php extension when installing Xdebug because we have copied the Php\ext DLL file into the Xdebug directory. Added a php.ini file to the

Extension=php_xdebug-2.1.0-5.3-vc6.dll?

This is the wrong Xdebug installation method and must be loaded in Zend mode.

This is the end of the basic installation tutorial for PHP xdebug, and we need to make some basic configuration for xdebug.

Xdebug Profiler Features Configuration Tutorials

  After installing Xdebug, we also need to do the basic configuration of Xdebug, the default xdebug PHP function automatic tracking (auto_trace) function, the parser function is not turned on, as the need to debug PHP code, some xdebug configuration options are best to open.

prior to this we need to create a directory of Xdebug auto-tracking and parser output files, make sure the directory is readable and writable , where I created the Xdebug\trace and Xdebug\profiler directories under D:\PHPWeb\.

Finally, complete the configuration of Xdebug in the php.ini configuration file and find

[xdebug]zend_extension= "C:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll"

? Add Xdebug configuration information after this

Xdebug.auto_trace=1xdebug.collect_params=1xdebug.collect_return=1xdebug.trace_output_dir= "D:/PHPWeb/xdebug/ Trace "xdebug.profiler_enable=1xdebug.profiler_output_dir=" D:/phpweb/xdebug/profiler "

? Finally save the php.ini and restart the Aapche server.

?

Test script execution time with Xdebug

Use Xdebug_time_index () to display time

Memory that the test script occupies:

Xdebug_memory_usage ()

Xdebug also provides a xdebug_peak_memory_usage () to see the peak memory consumption


Xdebug section configuration Options Description
Xdebug.auto_trace = 1
Whether to allow Xdebug trace function calls, trace information is stored as a file, the default value is 0

Collect_params = 1
Whether the Xdebug trace function parameter is allowed, the default value is 0

Xdebug.collect_return = 1
Whether the Xdebug trace function return value is allowed, the default value is 0

xdebug.profiler_enable = 1
Open Xdebug Performance Analyzer, stored as a file, this configuration cannot be configured with the Ini_set () function, the default value is 0

Xdebug.profiler_output_dir
Where the profiling file is stored, the default value is/tmp

Xdebug.profiler_output_name
A naming convention for profiling files, with a default value of cachegrind.out.%p

Xdebug.trace_output_dir
function call trace information output file directory, default value is/tmp

Xdebug.trace_output_name
function call trace information output file naming convention, default is trace.%c


Special Note: Xdebug's trace and Profiler's output file name rules can be changed, such as the name of the file named for the specific tracking php execution file name, process ID, random number, etc., very convenient, more xdebug configuration options description, Please refer to the XDEBUG configuration option Description on the official website.
At this point, the installation and configuration of the PHP debugging tool xdebug Tutorial Xdebug is finished, and the Xdebug How to configure it in Zend Studio and EditPlus will be introduced in the future.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.