A: Installation Method 1: Compile and install 1, download PHP XDebug extension, URL: xdebug.org # wgetpecl. php. netgetxdebug-2.1.2.tgz # tar-xzfxdebug-2.1.2.tgz # xdebug-2.1.2 # cdxdebug-2.1.2 # usrlocalphpbinphpize #. configure -- enable-
I. Installation Method 1: Compile and install 1. Download The XDebug extension of PHP. Website: http://xdebug.org/# wget http://pecl.php.net/get/xdebug-2.1.2.tgz # tar-xzf xdebug-2.1.2.tgz # xdebug-2.1.2 # cd xdebug-2.1.2 #/usr/local/php/bin/phpize #. /configure -- enable-
I. Installation
Installation Method 1: Compile and install
1. Download PHP XDebug extension, URL: http://xdebug.org/
# Wget http://pecl.php.net/get/xdebug-2.1.2.tgz
# Tar-xzf xdebug-2.1.2.tgz
# Xdebug-2.1.2
# Cd xdebug-2.1.2
#/Usr/local/php/bin/phpize
#./Configure -- enable-xdebug -- with-php-config =/usr/local/php/bin/php-config
# Make & make install
You do not need to copy xdebug. so. You can save the following.
# Cp modules/xdebug. so/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613
Note:/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/different PHP version paths are not necessarily placed in this path, you can specify xdebug in zend_extension_ts. so location.
========================================================== ==========
Installation Method 2: Automatic Installation
Http://pecl.php.net/package/xdebug
#/Usr/local/php/bin/pecl install xdebug
Installed successfully
Windows installation:
Note that you should use custom installation instructions. Put the content generated by your phpinfo to test and download the dll.
========================================================== ========
Ii. Modify the php configuration module
1. Configuration
Modify php. ini to remove the PHP acceleration module. Add the following configuration information to support XDebug extension.
Manual Installation
[Xdebug]
Zend_extension_ts = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug. so"
Xdebug. profiler_enable = on
Xdebug. trace_output_dir = "/tmp/xdebug"
Xdebug. profiler_output_dir = "/tmp/xdebug"
Automatic Installation
[Xdebug]
Extension = xdebug. so
Xdebug. profiler_enable = on
Xdebug. trace_output_dir = "/tmp/xdebug"
Xdebug. profiler_output_dir = "tmp/xdebug"
Configuration in Windows
Use phpinfo () to view the location of the php configuration file and add:
Extension = php_xdebug-2.2.0-5.3-vc9.dll [Xdebug]; turn on automatic tracking xdebug. auto_trace = On; Enable exception tracking xdebug. show_exception_trace = On; enable remote debugging to automatically start xdebug. remote_autostart = On; enable remote debugging xdebug. remote_enable = On; Collect variable xdebug. collect_vars = On; collect the returned value xdebug. collect_return = On; collect the xdebug parameter. collect_params = Onxdebug. remote_enable = onxdebug. remote_handler = dbgpxdebug. remote_host = 127.0.0.1xdebug.remote _ port = 9000 xdebug. profiler_enable = on; xdebug. trace_output_name = "% H. % s "xdebug. trace_output_dir = "E: \ PHPnow \ xdebug" xdebug. profiler_output_dir = "E: \ PHPnow \ xdebug"
------------------------------
2. Permission
Mkdir-p/tmp/xdebug
Chmod 755/tmp/xdebug
Chown www: www/tmp/xdebug
-----------------------------
3. Restart
/Usr/local/apache/bin/apachectl restart
NOTE: If phpinfo () is not printed, the configuration is not correct!
------------------------------
4. Disable
Note: If you do not analyze the system, you must disable xdebug. profiler. Otherwise, many files will be generated.
Xdebug. profiler_enable = off
==========================================
Iii. Analysis System
1. Access your website
Click various links on the home page several times. XDebug generates files in the/tmp/xdebug directory.
2. Use the graphic analysis tool wincachedgrind to analyze the generated file
: Http://sourceforge.net/projects/wincachegrind/files/
3. Download the executable version of the graphic tool kcachegrind in windows.
Http://sourceforge.net/projects/precompiledbin/files
Using kcachegrind, you can see more images. Note that you need to modify the PHP file path of the file executed from linux, so that you can use sourcecode.
View the code execution sequence
More complex code:
build( MINUTE ); } function build( $delay = 0 ) { if ( $delay <= 0 ) return; while ( $delay-- > 0 ) { } } } class Capsule extends Part { function Capsule() { parent::Part(); $this->build( CAPSULE * MINUTE ); } } class Booster extends Part { function Booster() { parent::Part(); $this->build( BOOSTER * MINUTE ); } } class Stage extends Part { function Stage() { parent::Part(); $this->build( STAGE * MINUTE ); } } class SpaceShip { var $booster; var $capsule; var $stages; function SpaceShip( $numberStages = 3 ) { $this->booster = new Booster(); $this->capsule = new Capsule(); $this->stages = array(); while ( $numberStages-- >= 0 ) { $stages[$numberStages] = new Stage(); } } } $toys = array(); $count = PRODUCTION; while ( $count-- >= 0 ) { $toys[] = new SpaceShip( 2 ); }?>Toy Factory Output Toy Production Built
Analyze logs
For other usage instructions, see xdebug basic usage.
==========================================
Reference
"
Speed up, speed up, and speed up PHP applications !, Part 1: Analyze PHP applications to find, diagnose, and accelerate slow-Running code
Http://www.ibm.com/developerworks/cn/opensource/os-php-fastapps2/index.html
Http://hi.baidu.com/%D4%E7%B9%C8%C9%E7%C7%F8/blog/item/d8fedafb7843c66b024f56cb.html
Use Xdebug to track Code Execution
Http://book.51cto.com/art/200906/126516.htm
KCacheGrind replacement solution in windows
- WinCacheGrind
It can be used to analyze the cachegrind. xxx release produced by xdebug and the kcachegrind of the easy-to-use release.
- Windows port of kcachegrind
From the original linux kcachegrind, You can renew the version on windows. The function is the same as that of linux kcachegrind.
- Webgrind
The online version of callgrind, with xdebug, can be used as the php script profile on the instant release.
==========================================
Configure Xdebug in NetBeans
Http://blog.csdn.net/21aspnet/article/details/6754034
==========================================
There is also a great extension:
Http://pecl.php.net/package/xhprof
Installation Reference:
Http://www.phpv5.com/blog/archives/66
Refer:
Tune squid 2.7 notes with kcachegrind
Http://blog.sunyixing.com/archives/378