Php xdebug installation, configuration, and debugging skills

Source: Internet
Author: User
Tags vc9 zts

Xdebug is a php code execution tool that can test the performance of each stage of our php code, so that we can optimize the number of code in a timely manner, next I will give you the xdebug and xdebug debugging skills.

Windows xdebug configuration and installation

1. Download Xdebug

: Http://xdebug.org/download.php
The latest version is 2.1.2 and has many versions. There are 32-bit and 64-bit differences, the differences between VC6 and VC9, and the difference in thread security.


<? PHP phpinfo ();?> Save to test. php, save the server directory, and open it in a browser. Find Compiler (VC6 if not), Architecture (the value of Configure Command if not), and Thread Safety in the previous Info. For example, you should download a 32-bit VC9 thread safe (PHP 5.3 VC9 TS (32 bit ))

2. Install Xdebug
If you have configured PHP, change the downloaded file to php_xdebug.dll (it doesn't matter if you don't change it, just to look good), and put down the ext folder in the PHP installation directory.

3. Configure Xdebug

Xdebug has many configuration projects, so I only know a few of them. Modify the PHP. ini file in the php installation directory and insert the following code at the end of the file:
[Xdebug]

The Code is as follows: Copy code

Zend_extension = "E: APMServPHPextphp_xdebug.dll"

Xdebug. auto_trace = On
; It is best to set automatic tracking at the beginning, otherwise it will not be enabled

Xdebug. profiler_enable = on

Xdebug. trace_output_dir = "E: APMServxdebug"

Xdebug. profiler_output_dir = "E: APMServxdebug"

; Maximum number of Recursion

Xdebug. max_nesting_level = 100

; Override var_dump ()

Xdebug. overload_var_dump = On

When this parameter is set to 1, xdebug enforces exception tracking even if an exception is caught.

Xdebug. show_exception_trace = 1

 

Xdebug. show_local_vars = 1


Xdebug. collect_params = On

Xdebug. collect_return = On

Xdebug. collect_vars = On

Xdebug. dump_undefined = On

Xdebug. profiler_enable_trigger = On

 

; Allow remote connection

Xdebug. remote_enable = true

; IP address of the zs IDE that allows remote connection

Xdebug. remote_host = 192.168.0.51

Zendstudio Port

Xdebug. remote_port = 9000

Zendstudio application layer communication protocol

Xdebug. remote_handler = dbgp

Xdebug. extended_info = "1"


Because I don't want to have a Log file (because the file is growing fast and has a GB or two days later), I commented out trace_output_dir and profiler_output_dir, note that Xdebug does not automatically create a directory. You must ensure that the directory actually exists. As for the other items, they are all default values. Therefore, the values are listed because they may be changed. Now, refresh the phpinfo () page to see the Xdebug information.


Linux xdebug configuration and installation


Xdebug is a module of php and needs to be compiled and installed. php installed with lnmp is installed to/usr/local/php by default, and a hard link to/usr/bin is made.

Compile xdebug first

The Code is as follows: Copy code

Wget http://www.xdebug.org/files/xdebug-2.2.3.tgz
Tar xzf xdebug-2.2.3.tgz
Cd xdebug-2.2.3
/Usr/bin/phpize
./Configure -- with-php-config =/usr/local/php/bin/php-config

Modify php. ini configuration

Add the following

The Code is as follows: Copy code

; No-debug-non-zts-20090626 this folder name and php version are one-to-one correspondence

Zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xdebug. so"

Xdebug. default_enable = On
Xdebug. show_exception_trace = On
Xdebug. show_local_vars = 1
Xdebug. max_nesting_level = 50
Xdebug. var_display_max_depth = 6

Xdebug. dump_once = On
Xdebug. dump_globals = On
Xdebug. dump_undefined = On
Xdebug. dump. REQUEST = *
Xdebug. cli_color = 2

Restart php-fpm, write the wrong php code at will, and refresh the browser to see the error prompt.

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.