PHP xdebug installation configuration and debugging PHP tips _php Tutorial

Source: Internet
Author: User
Tags phpinfo vc9 zts
Xdebug is a PHP code execution height tool, it can test the performance of our PHP code at all stages, so that we can do several code optimization in a timely manner, the following I will give you from the configuration of Xdebug and Xdebug debugging skills.

Windows Xdebug Configuration Installation

1. Download Xdebug

Download Address: http://xdebug.org/download.php
The latest version is 2.1.2, with many versions, with 32-bit and 64-bit differences, differences between VC6 and VC9, and thread safety or not.


Save to test.php, save the server directory, open through the browser. In the first info, find compiler (no VC6), Architecture (not the value of Configure command) and thread Safety. For example, you should download the 32-bit VC9 thread-safe (PHP 5.3 VC9 TS (three bit))

2. Installing Xdebug
If you've already configured PHP, rename the downloaded file to Php_xdebug.dll (it doesn't matter, just to look good), put down the Ext folder of the PHP installation directory.

3. Configure Xdebug

Xdebug a lot of configuration items, I only know a very small part, so just talk about the usual. To modify the PHP installation directory's php.ini file, 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
Auto-tracking settings are best set at the front, otherwise they won't turn on

Xdebug.profiler_enable=on

Xdebug.trace_output_dir= "E:apmservxdebug"

Xdebug.profiler_output_dir= "E:apmservxdebug"

; Maximum recursive number

xdebug.max_nesting_level=100

; rewrite Var_dump ()

Xdebug.overload_var_dump = On

When this parameter is set to 1 o'clock, Xdebug will still force exception tracking even if an exception is caught when an exception occurs

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 connections

Xdebug.remote_enable=true

The IP address of the ZS IDE that allows remote connections

xdebug.remote_host=192.168.0.51

; Zendstudio set the port

xdebug.remote_port=9000

; Zendstudio application-Layer communication protocol

Xdebug.remote_handler=dbgp

xdebug.extended_info= "1"


Because I do not want to have a log file (because the file grows fast, not two days there is one or two g), so the Trace_output_dir and Profiler_output_dir commented out, to note that Xdebug will not automatically build the directory, You must ensure that the set directory is actually present. As for the others, it is the default value, so the note is dropped, because it may change, so the column comes out. Now refresh the phpinfo () page, you should be able to see the xdebug information.


Linux Xdebug Configuration Installation


Xdebug is a module of PHP, need to compile the installation, I use LNMP installed php,php is installed by default to/usr/local/php, and then do a hard link to/usr/bin

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

Modifying the php.ini configuration

Add the following to the

The code is as follows Copy Code

no-debug-non-zts-20090626 this folder name and PHP version are one by one corresponding

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, refresh the browser, you can see the error message

http://www.bkjia.com/PHPjc/629820.html www.bkjia.com true http://www.bkjia.com/PHPjc/629820.html techarticle Xdebug is a PHP code execution height tool, it can test the performance of our PHP code at all stages, so that we can be in a timely manner to optimize the number of code, the following I will give big ...

  • Related Article

    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.