The role of Xdebug and its installation configuration are described in detail _ PHP Tutorial

Source: Internet
Author: User
Detailed description of the role and installation configuration of Xdebug. Speaking of PHP code debugging, for experienced PHPer, through simple echo, print_r, var_dump functions, or PHP development tools zendstudio and editplus can quickly solve the problem of PHP code debugging in the work. for experienced PHPer, through simple echo, print_r, var_dump functions, or the PHP development tools zend studio and editplus can quickly solve most of the problems encountered in the work. However, for new PHP users, they only use these simple debugging statements to locate and solve the problem, it is still quite difficult, and Xdebug, as a code debugging tool designed for php, is undoubtedly a huge boon to us.

As a PHP debugging tool, Xdebug provides a variety of debugging functions. by enabling the auto_trace and analyzer functions, you can intuitively view the performance data of PHP source code, this provides great convenience for optimizing PHP code. Today, I will share with you the installation and configuration of PHP source code performance debugging tool Xdebug.

The installation configuration of Xdebug in PHP involves the modification of the php. ini configuration file.

First download and install Xdebug:
(1) log on to www.xdebug.org/, there is a download/SVN in the home navigation bar, click to enter the download page, select Xdebug 2.1.0rc1 under the 5.2 VC6 (32 bit), download the php_xdebug-2.1.0RC1-5.2-vc6.dll file;
(2) put the downloaded php_xdebug-2.1.0RC1-5.2-vc6.dll in the C: \ php5 \ ext directory and rename it php_xdebug.dll;
Next, modify the configuration file php. ini:
(3) edit php. ini and add the following lines:

[Xdebug]zend_extension="c:/php5/ext/php_xdebug-2.1.0RC1-5.2-vc6.dll"

# Note: zend_extension_ts is used when Xdebug is configured in PHP5.3 or earlier versions. for PHP5.3 or later versions, zend_extension is used.
(4) restart Apache and use the phpinfo () function to view the installation information of Xdebug. if xdebug is displayed in the output, the installation and configuration are successful.
After the above steps, the basic installation of Xdebug is complete. below we need to make some basic configuration for Xdebug.
Xdebug Configuration tutorial
After installing Xdebug, we also need to make basic configuration for Xdebug. by default, the PHP function auto-tracking (auto_trace) function and analyzer function of Xdebug are not enabled, which is required for debugging PHP code, some Xdebug configuration options are recommended to be enabled.

Before that, we need to create an Xdebug automatic tracking directory and a directory for storing the output file of the analyzer. make sure that the directory is read and written. here I am at D: the xdebug \ trace and xdebug \ profiler directories are created under \ PHPWeb.

Finally, complete the Xdebug configuration in the php. ini configuration file. add the following code segment to the code segment for configuring Xdebug:

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 php. ini and restart the Aapche server.

The following describes the configuration options of Xdebug:

Xdebug. auto_trace = 1
Whether to allow Xdebug to trace function calls. trace information is stored as files. the default value is 0.

Collect_params = 1
Whether to allow Xdebug to trace function parameters. the default value is 0.

Xdebug. collect_return = 1
Whether to allow Xdebug to trace function return values. the default value is 0.

Xdebug. profiler_enable = 1
Open the xdebug performance analyzer and store it as a file. this configuration cannot be configured using the ini_set () function. the default value is 0.

Xdebug. profiler_output_dir
Storage location of performance analysis files; default value:/tmp

Xdebug. profiler_output_name
Naming rules for performance analysis files. the default value is cachegrind. out. % p.

Xdebug. trace_output_dir
Directory of the output file of the function call trace information. the default value is/tmp.

Xdebug. trace_output_name
Naming rules for output file of function call trace information. the default value is trace. % c.

Note: The Xdebug trace and profiler output file name rules can be changed. for example, it is very convenient to name the file name as the PHP execution file name, process ID, and random number of the specific trail, for more instructions on Xdebug configuration options, refer to the instructions on Xdebug configuration options on the official website.

Now the installation and configuration of Xdebug in the Xdebug tutorial of PHP debugging tool is complete. I hope it will be helpful to you.

Articles you may be interested in
  • How to install and configure the PHP runtime environment in Windows 7
  • Install and configure memcache in windows
  • Differences between window. navigate and window. location. href
  • Detailed configuration of Uploadify (JQuery Upload plug-in)
  • Mysql installation and configuration tutorial (graphic explanation)
  • How to use zlib to compress output content to speed up web page opening
  • JS obtains the key code, how Js Shields users' keys, and Js obtains the ASII code corresponding to users' keys (compatible with all browsers)
  • Vcastr 3.0-detailed instructions on downloading and configuration of flash video (flvplayer)

Parse studio and editplus can quickly solve problems encountered in the work...

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.