Revenue Source

Welcome to the Revenue Source affiliate marketing forums.

You are viewing our internet marketing and SEO forums as a guest which gives you limited access to most of our discussions.  By joining our free community, you will have access to post affiliate marketing topics, communicate privately with other members (PM), exchange SEO strategies, and access many other special features.  Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems, please don't hesitate to contact us.

Go Back   Revenue Source > Site Design & Development > Programming Help
Reload this Page Tutorial: An Introduction to XDebug
Tags: , ,

Reply
 
LinkBack Thread Tools Search this Thread
Old
  (#1 (permalink))
Affiliate Blogs is Offline
Revenue Source Veteran
Affiliate Blogs has a brilliant future here!
 
Affiliate Blogs's Avatar
 
Join Date: Oct 2005
Posts: 8,626
Jack of All Trades
CyberSpace United States
   
Tutorial: An Introduction to XDebug - 05-04-2007

by Matt
Introduction
Xdebug is an Open Source PHP extension for code debugging and profiling. Installation is straightforward and it will provide you with a wealth of information about your code, without being intrusive. One of the great features of Xdebug is, since it runs as an extension, there is no need to actually alter your code.
Install
Installation is simple, especially if you use on of the pre-compiled binaries provided on the site. Since i use XAMPP for for my development I grabbed the latest windows DLL and made the following change to my php.ini:
PHP Code:
zend_extension_ts="C:Program Filesxamppphpextensionsphp_xdebug-2.0.0rc3-5.2.1.dll" 
Xdebug currently conflicts with the Zend optimizer and any other Zend extension (DBG, APC, APD etc)- although I've read about people having success, so combine at the your own risk.
You can confirm the installation went well by making a simple php_info() script. Full instructions and steps for rolling your own binary are available on the Xdebug install page.
Debugging
Without doing anything you'll see the benefits of Xdebug when messages are outputted to your browser.
Here's a simple script with a PHP warning. Xdebug generates a colorful back-trace showing the steps that generated the notice.

Xdebug has a host of options to customize what, how, and where all the information it gathers is relayed to the developer.By enabling the Xdebug extension you also open up a set of Xdebug functions that can be used directly in your code. These are useful for quick debugging, but anything more you may end up bits of debug code spread throughout your site, which is exactly what you should using Xdebug to avoid in the first place.
The alternatives are to use Xdebug's remote debugging and profiling abilities.
Remote Debugging
Remote debugging requires a few more configuration changes, plus a client application that connects to your server for live debugging. The setup and use of the remote debugger goes a bit beyond the scope of this article. Needless to say it is an extremely powerful feature.
Profiling
Thanks to Xdebug's profiling ability you'll never have to write code like this again:
PHP Code:
function getmicrotime() {   list($usec$sec) = explode(" "microtime());   return ((float)$usec + (float)$sec);}$time_start getmicrotime();$m = new main;$time_end getmicrotime();$time $time_end $time_start;echo "Exec time: " $time "secondsn"
With the addition of a couple of lines to your htaccess, Xdebug will output detailed information about the processing of your script. The actual data can viewed using WinCacheGrind on Windows or KCacheGrind on Linux. The viewer provides an easy way to understand what goes into the execution of a script, as well as how long each part is taking.
Conclusion
The setup time and learning curve for the basic debug and profiling features of Xdebug are so low there really isn't any excuse to not be using them already. It only takes 15 minutes getting Xdebug configured and another 15 minutes getting to know it's features to make yourself a smarter, faster developer.


Tutorial: An Introduction to XDebug - Read More...
  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Tutorial: An Introduction to XDebug
Thread Thread Starter Forum Replies Last Post
Derick Rethans' Blog: Xdebug 2.0.0RC2 Affiliate Blogs Programming Help 0 12-27-2006 03:19 PM
ThinkPHP Blog: Eclipse, PHP and XDebug Affiliate Blogs Programming Help 0 11-28-2006 08:16 PM
Tutorial: An Introduction to OOP in PHP Affiliate Blogs Programming Help 0 11-28-2006 05:08 AM
Tutorial: A Simple Sessions Tutorial Affiliate Blogs Programming Help 0 11-28-2006 05:08 AM
HTMLGoodies.com: PHP Tutorial - Introduction Affiliate Blogs Programming Help 0 11-28-2006 05:08 AM



© 2004-6 RevenueSource.com.  All rights reserved.  Do not duplicate or redistribute in any form.
This website and its logos/design are property of RevenueSource.com.  All rights reserved. vBSEO 3.2.0 RC7


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34