PHP debugging tool Xdebug installation and configuration tutorial

Source: Internet
Author: User

Speaking of PHP code debugging, for experienced PHPer, most problems can be solved through echo, print_r, var_dump functions, or PHP development tools zend studio and editplus, however, it is difficult for children's shoes to get started with PHP, and it is difficult to accurately detect PHP performance problems only through the above PHP debugging methods, xdebug is a very useful PHP debugging tool.

Xdebug, as a PHP debugging tool, provides a wide range of debugging functions. You can also configure Xdebug installation as zend studio and editplus to debug third-party PHP plug-ins. By enabling auto_trace) and analyzer function, you can intuitively see the performance data of PHP source code, in order to optimize PHP code. Today, I will share with you the basic knowledge of installing and configuring the PHP debugging tool Xdebug.

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

  Xdebug installation tutorial

  Download Xdebug

First, we need to download Xdebug. Make sure to select the appropriate Xdebug version based on the installed PHP version. Because I installed PHP in Windows, so choose to download the Windows version of Xdebug2.1.0 (5.3 VC6 (32 bit), the downloaded Xdebug file for the php_xdebug-2.1.0-5.3-vc6.dll, this is because Xdebug is installed as a PHP module configuration and use.

  Xdebug installation prompt: If you do not know the installed PHP version, you can refer to the phpinfo () function. Xdebug also provides the phpinfo output information analysis tool to help you analyze how to install Xdebug, copy and submit the phpinfo output information. Address: Xdebug phpinfo Information Analysis address.

  Install Xdebug

Copy the downloaded php_xdebug-2.1.0-5.3-vc6.dll to the ext directory under the PHP installation directory, which is C: \ php \ ext, which is used to store the PHP extension library DLL file.

  Configure php. ini

The last step to install Xdebug is to configure the php. ini file, open the php. ini configuration file under the C: \ php Directory, and add

[Xdebug]
Zend_extension = "c:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll"

 

 

 

Restart the Apache server and use the phpinfo () function.

 

 

 

  Xdebug configuration prompt: Zend_extension_ts is used when Xdebug is configured in versions earlier than PHP5.3. For PHP5.3 and later versions, zend_extension is used.

  Reason why xdebug not loaded as zend extension information appears

The reason why xdebug not loaded as zend extension occurs is that when Xdebug is installed, we copy the Xdebug DLL file to the php \ ext directory, and it is easy to load Xdebug AS a php extension library, in php. INI file added

Extension = php_xdebug-2.1.0-5.3-vc6.dll

 

 

This is an incorrect Xdebug installation method and must be loaded in zend mode.

Now the PHP Xdebug Basic installation tutorial 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 and find

[Xdebug]
Zend_extension = "c:/php/ext/php_xdebug-2.1.0-5.3-vc6.dll"

 

 

After that, add the Xdebug configuration information

 

Code

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

Configuration options in 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: Xdebug trace and profiler output file name rules can be changed. For example, naming a file name as the PHP Execution file name, process ID, and random number of a specific trail is very convenient, 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. In the future, we will introduce how to configure and use Xdebug in zend studio and editplus.

 

 

 

From: http://www.leapsoul.cn /? P = 935

 

 

 

Personal Configuration backup:

 

[XDebug]
Zend_extension = "D: \ php \ xampp \ php \ ext \ php_xdebug.dll"
Xdebug. remote_enable = true
Xdebug. remote_host = 127.0.0.1
Xdebug. remote_port = 9000
Xdebug. remote_handler = dbgp

 

 

 

 

 

 

 

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.