<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Straylight Run &#187; xdebug</title> <atom:link href="http://blog.straylightrun.net/tag/xdebug/feed/" rel="self" type="application/rss+xml" /><link>http://blog.straylightrun.net</link> <description>Software, Technology, PHP</description> <lastBuildDate>Wed, 25 Apr 2012 16:11:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Unit Testing And Coverage With Phing</title><link>http://blog.straylightrun.net/2009/05/05/unit-testing-and-coverage-with-phing/</link> <comments>http://blog.straylightrun.net/2009/05/05/unit-testing-and-coverage-with-phing/#comments</comments> <pubDate>Wed, 06 May 2009 04:18:44 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Process]]></category> <category><![CDATA[build server]]></category> <category><![CDATA[phing]]></category> <category><![CDATA[phpunit]]></category> <category><![CDATA[xdebug]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2009/05/05/unit-testing-and-coverage-with-phing/</guid> <description><![CDATA[If we are to do unit testing, then it would be nice to have a simple way to run all the tests at once.&#160; And seeing the results in a command line is fine, but it would be nice to be able to generate some pretty reports I could view in a browser.&#160; And running [...]]]></description> <content:encoded><![CDATA[<p>If we are to do unit testing, then it would be nice to have a simple way to run all the tests at once.&nbsp; And seeing the results in a command line is fine, but it would be nice to be able to generate some pretty reports I could view in a browser.&nbsp; And running coverage tools from the command line to see exactly what we&#8217;re testing is fine, but it would be nice to be able to generate coverage reports I could view in a browser. It would be nice to be able to do all these things with one simple command.<p>The command: <a
href="http://phing.info/trac/">phing</a>.<p>If you&#8217;re familiar with <a
href="http://ant.apache.org/">Ant</a> for Java, phing is functionally identical to ant.&nbsp; With a very simple build script, I can run all the unit tests, and generate test result reports and coverage reports in HTML automatically. Then I can fire up my browser and see if any tests failed, or whether we need new tests.<p>The following are examples of test results reports and coverage reports.<p><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/testresults.png"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="324" alt="Unit test results" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/testresults-thumb.png" width="404" border="0"></a><p><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/coverage.png"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="324" alt="Code coverage report" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/coverage-thumb.png" width="404" border="0"></a><p>Phing currently requires <a
href="http://www.phpunit.de/">PHPUnit</a> for unit testing and <a
href="http://xdebug.org">xdebug</a> for coverage. Someone would have to write a task to use other frameworks such as <a
href="http://www.simpletest.org">SimpleTest</a>.<p>The phing build file is a first step towards automating builds with a build server. A build server can periodically check the project for changes. If new code exists, it will run tests and generate reports for tests, coverage, lint, anything. It can put all this on the web for easy inspection. It can keep versions of the whole project that be can be readily deployed.&nbsp; So if we have a staging and production server, and we stick to deploying ONLY bundles from the build server, it can make deployment and maintenance easier.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/05/05/unit-testing-and-coverage-with-phing/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Xdebug</title><link>http://blog.straylightrun.net/2009/02/23/xdebug/</link> <comments>http://blog.straylightrun.net/2009/02/23/xdebug/#comments</comments> <pubDate>Mon, 23 Feb 2009 19:00:09 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[Performance]]></category> <category><![CDATA[debugging]]></category> <category><![CDATA[kcachegrind]]></category> <category><![CDATA[profiling]]></category> <category><![CDATA[xdebug]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2009/02/23/xdebug/</guid> <description><![CDATA[Xdebug is an indispensable PHP tool. It is a PHP extension that adds a wealth of capabilities to your PHP development.&#160; There are so many features, I&#8217;ll dive right in. var_dump() Replacement Xdebug replaces PHP&#8217;s var_dump() function for displaying variables. Xdebug&#8217;s version includes different colors for different types and places limits on the amount of [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://xdebug.org">Xdebug </a>is an indispensable PHP tool. It is a PHP extension that adds a wealth of capabilities to your PHP development.&nbsp; There are so many features, I&#8217;ll dive right in.</p><p><u><code>var_dump()</code> Replacement</u></p><blockquote><p>Xdebug replaces PHP&#8217;s var_dump() function for displaying variables. Xdebug&#8217;s version includes different colors for different types and places limits on the amount of array elements/object properties, maximum depth and string lengths. There are a few other functions&#8230;</p></blockquote><p>My favorite part about this: the output is already pre-formatted, so no more echoing <code>&lt;pre&gt;</code> before every <code>var_dump().</code></p><p><u>Stack Traces For Free </u></p><blockquote><p>When Xdebug is activated it will show a stack trace whenever PHP decides to show a notice, warning, error etc. The information that stack traces display, and the way how they are presented, can be configured to suit your needs.</p></blockquote><p>Even if you have <a
href="http://www.php.net/manual/en/ref.errorfunc.php#ini.display-errors"><code>display_errors</code></a> off and all errors are sent to a log, the log will still contain the stack traces of any errors.</p><p><u>Function Traces</u></p><blockquote><p>Xdebug allows you to log all function calls, including parameters and return values to a file in different formats.</p></blockquote><p>This is the ultimate debugging trace. It will create a file with every function, including third-party libraries and PHP internal functions, that was executed along with its arguments. It also displays the execution time the function was called at (where 0 is the start of the request), and the total amount of memory used at that point.&nbsp; What I like to do is insert <code>xdebug_start_trace()</code> in the bootstrap file at the start of the page request.&nbsp; I wrap a condition around it to enable it by giving a secret GET parameter on the query string.</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'debugflag'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   xdebug_start_trace<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p><u>Profiling</u></p><blockquote><p>Xdebug&#8217;s built-in profiler allows you to find bottlenecks in your script and visualize those with an external tool such as KCacheGrind or WinCacheGrind.</p></blockquote><p>Xdebug, in conjunction with <a
href="http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindIndex">KCacheGrind</a>, can generate a profile call graph which serves as the ultimate profiling report.&nbsp; First, generate a cachegrind file from Xdebug by appending XDEBUG_PROFILE as a GET pararmeter to the URL of the page you want to profile.&nbsp; After the page loads, you will find a cachegrind output file in the output directory (specified in xdebug.ini).&nbsp; Run KCacheGrind and open the output file. You can then generate a call graph which looks something like this:</p><p><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/02/kcgshotcg.png"><img
style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="485" alt="KCacheGrind call graph" src="http://blog.straylightrun.net/wp-content/uploads/2009/02/kcgshotcg-thumb.png" width="393" border="0"></a></p><p>Limitations:</p><ul><li>KCacheGrind only runs on some kind of Unix. I attempted to run it on Windows/Cygwin unsuccessfully. There is a <a
href="http://sourceforge.net/projects/wincachegrind">WinCacheGrind</a>, but it does not offer the call graph feature.<li>The call graph feature requires that the source code be local (this info is contained in the cachegrind file). Which means you have to run KCacheGrind on the server, or synchronize the code on the server locally.</li></ul> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/02/23/xdebug/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
