<?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>Brettic.us &#187; Netbeans</title>
	<atom:link href="http://brettic.us/category/tech/programming/netbeans/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettic.us</link>
	<description>Web devlopment and life in general</description>
	<lastBuildDate>Fri, 23 Mar 2012 16:58:25 +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>Debugging PHP on a Mac with XDebug, Firefox and Netbeans</title>
		<link>http://brettic.us/2009/11/07/developing-php-on-a-mac-with-netbeans/</link>
		<comments>http://brettic.us/2009/11/07/developing-php-on-a-mac-with-netbeans/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 06:07:28 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://brettic.us/?p=202</guid>
		<description><![CDATA[<img src="http://brettic.us/wp-content/uploads/2010/10/codeigniter.png" width="48" height="48" alt="" title="CodeIgniter" /><br/>After nearly two months of using OS X, I think I have finally found my groove when it comes to doing my job. That is, writing code for websites, mainly in PHP. For many years prior to using a Mac for PHP development, I had been using Windows or Linux and Zend Studio 5.x. When [...]]]></description>
			<content:encoded><![CDATA[<img src="http://brettic.us/wp-content/uploads/2010/10/codeigniter.png" width="48" height="48" alt="" title="CodeIgniter" /><br/><p>After nearly two months of using OS X, I think I have finally found my groove when it comes to doing my job.  That is, writing code for websites, mainly in PHP.</p>
<p>For many years prior to using a Mac for PHP development, I had been using Windows or Linux and Zend Studio 5.x. When I was looking several months back for the Mac version download for my Zend Studio license, I was presented, instead, with a free upgrade to version 6. Wow, that was nice Zend! Unfortunately, the version I paid for (the &#8220;perpetual&#8221; license) was no longer there to download.</p>
<blockquote><p>UPDATE: As of my last login to Zend, the 5.5.1 download was available. I installed and everything worked well. Still using Netbeans but appreciated all the same.</p></blockquote>
<p>But hey! I got the brand-new version. That&#8217;s great right? Wrong! Zend decided to drink the Eclipse Kool Aid and completely changed an IDE that I had grown accustomed to (I guess it&#8217;s only fair to point out that Zend Studio 5.x was so old at this point that it was getting increasingly more difficult to install on more modern operating systems and newer java platforms.) In spite of the seemingly &#8220;over-bloat&#8221; of Zend Studio 6.0, I decided to give it a try. I must say that everything just felt wrong. Now I&#8217;m sure there are many PHP developers out there that have been using Eclipse for years and can&#8217;t live without it, but I just couldn&#8217;t seem to make it work my voodoo. I didn&#8217;t have the patience to get my Eclipse PHD, so I went looking elsewhere. That led me to a surprising alternative: <a href="http://www.netbeans.org/features/php/">Netbeans</a>. Although very similar to Eclipse, an IDE with modules/plug-ins for multiple computer language support, Netbeans (entirely free) impressed me right on the spot. I know Zend Studio has all the same features more or less, but the way Netbeans is put together just seemed more natural to me (things I wanted to do actually worked.) Let it suffice to say that I have been using Netbeans since then and I haven&#8217;t looked back!</p>
<p>In this post, we will discover how to go about debugging a specific page in your website through setting up debugging in your MAMP stack, the free Netbeans IDE and your Firefox browser.</p>
<p><span id="more-202"></span></p>
<h2>Setting up Debugging with Xdebug and Firefox</h2>
<p>In order to leverage the new-found versatility or <a href="http://www.mamp.info/en/mamp/index.html">MAMP</a>, I needed a good debugger. I had had a pretty decent debugger with Zend Studio 5.x and that would be an essential requirement for netbeans. One of the cool features of Zend Studio was the integration of the Zend Toolbar with the debugger. Fortunately, this can be done with netbeans also, but you have to get a firefox plugin called <span style="text-decoration: line-through;">Xdebug Helper</span> <a title="easy Xdebug" href="https://addons.mozilla.org/en-US/firefox/addon/58688/" target="_blank">easy Xdebug</a>. When you get it, note that it has one configuration option you need to set: Xdebug.idekey needs to be set to <strong>netbeans-xdebug</strong>.</p>
<p><a href="http://brettic.us/wp-content/uploads/2010/05/Picture-2.png"><img class="size-medium wp-image-298 alignnone" style="margin: 10px; border: 0pt none;" title="easy Xdebug" src="http://brettic.us/wp-content/uploads/2010/05/Picture-2-300x293.png" alt="" width="300" height="293" /></a></p>
<p>Since I was using MAMP, I needed to install the xdebug extension for PHP. I actually downloaded the source and built the extension (used Xcode tools to phpize the source and build it and then just copied it to the appropriate MAMP folder.) I wish I had taken the time to record the steps involved, but instead I&#8217;ll just refer you to <a href="http://debuggable.com/posts/setting-up-xdebug-on-mac-os-x-or-win32-linux:480f4dd6-0240-4a90-8fa1-4e41cbdd56cb">the easy way</a>. Now we just need a little change in our php.ini file and we are good to go:</p>
<blockquote><p>Note: As of MAMP version 1.8.4, there is an xdebug extension that comes with MAMP (just be sure to disable Zend Optimizer since they don&#8217;t seem to play well together.)</p></blockquote>
<p><code>; Xdebug config for Mac OS X and NetBeans IDE<br />
zend_extension=/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/xdebug.so<br />
xdebug.remote_enable=1<br />
xdebug.remote_handler=dbgp<br />
xdebug.remote_mode=req<br />
xdebug.remote_host=127.0.0.1<br />
xdebug.remote_port=9000</code></p>
<div id="attachment_213" class="wp-caption alignnone" style="width: 310px"><a href="http://brettic.us/wp-content/uploads/2009/11/Picture-3.png"><img class="size-medium wp-image-213" title="Xdebug in php.ini" src="http://brettic.us/wp-content/uploads/2009/11/Picture-3-300x198.png" alt="Xdebug in php.ini" width="300" height="198" /></a><p class="wp-caption-text">Xdebug in php.ini</p></div>
<p>Now, all we have to do in order to debug is evoke the debugger in netbeans. I do this by clicking on the debug project button in the netbeans toolbar:</p>
<div id="attachment_221" class="wp-caption alignnone" style="width: 310px"><a href="http://brettic.us/wp-content/uploads/2009/11/Picture-2.png"><img class="size-medium wp-image-221" title="button" src="http://brettic.us/wp-content/uploads/2009/11/Picture-2-300x92.png" alt="netbeans debug button" width="300" height="92" /></a><p class="wp-caption-text">netbeans debug button</p></div>
<p>Netbeans will open up your development website according to the URL you submitted when creating the project (make sure firefox is your default browser and that you have set the default page in your project.)</p>
<blockquote><p><strong>Tip! </strong>You can also force Netbeans to not open your browser when you debug:</p>
<p style="padding-left: 30px;">In your project properties (right click on the project -&gt;  properties), click on Run Configuration, look for the “Advanced…” button  and set “<strong>Do Not Open Web Browser</strong>“. Click OK.</p>
<p>A big thanks to <a href="http://www.leonardteo.com/2010/08/getting-php-xdebug-codeigniter-and-netbeans-to-all-work-nicely-together/" target="_blank">Leonard Teo</a> for this tip.</p>
</blockquote>
<p>Often, just clicking the button will automatically activate the Xdebug Helper addon for me. But if you want to make sure that netbeans debugs the URL in your browser, be sure the click the X in your firefox footer bar so that it changes color from gray to green.</p>
<div id="attachment_222" class="wp-caption alignnone" style="width: 310px"><a href="http://brettic.us/wp-content/uploads/2009/11/Picture-31.png"><img class="size-medium wp-image-222" title="Xdebug Helper Toogle Icon" src="http://brettic.us/wp-content/uploads/2009/11/Picture-31-300x272.png" alt="Xdebug Helper Toogle Icon" width="300" height="272" /></a><p class="wp-caption-text">Xdebug Helper Toogle Icon</p></div>
<p>Netbeans will open your startup page to something like:<br />
<code><br />
index.php?XDEBUG_SESSION_START=netbeans-xdebug</code></p>
<p>If you are using a PHP framework like <a href="http://codeigniter.com/">Codeigniter</a>, the URL can be a little annoying at first. I have found that I only need to press the continue button to let the start page run it&#8217;s path and then just close that tab. From that point I just leave the debugger running and toggle the Xdebug Helper &#8220;X&#8221; icon when I need to debug any page that I am working on. Couldn&#8217;t be easier!</p>
<h2>Screencast Tutorials</h2>
<p>The following screencasts cover making XDebug and Netbeans work together. It&#8217;s a recap of the text here with some added instruction on setting up an Apache virtual host for development from your computer. Please note, I do not have the ability to be concise when I speak and you may lose patience. My apologies up front. (If you want a condensed version, just watch Part 2 and than skip to Part 6. You might want to watch Part 5 if 6 leaves you scratching your head.) Also, as many people find when they listen to themselves recorded, I find that my voice and accent sounds kind of strange and annoying. That&#8217;s one part me and another part Southern Utah accent. Bear with me if you can. <img src='http://brettic.us/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3 style="text-align: left;">Part 1: Prerequites for Xdebug and PHP on a Mac</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="i=43318" /><param name="allowFullScreen" value="true" /><param name="src" value="http://screenr.com/Content/assets/screenr_1116090935.swf" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="345" src="http://screenr.com/Content/assets/screenr_1116090935.swf" allowfullscreen="true" flashvars="i=43318"></embed></object></p>
<h3>Part 2: Setting up XDebug Helper</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="i=43319" /><param name="allowFullScreen" value="true" /><param name="src" value="http://screenr.com/Content/assets/screenr_1116090935.swf" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="345" src="http://screenr.com/Content/assets/screenr_1116090935.swf" allowfullscreen="true" flashvars="i=43319"></embed></object></p>
<h3>Part 3: Setting up an virtualhost apache environment in MAMP for codeigniter</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="i=43320" /><param name="allowFullScreen" value="true" /><param name="src" value="http://screenr.com/Content/assets/screenr_1116090935.swf" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="345" src="http://screenr.com/Content/assets/screenr_1116090935.swf" allowfullscreen="true" flashvars="i=43320"></embed></object></p>
<h3>Part 4: Starting to use XDebug in Netbeans</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="i=43322" /><param name="allowFullScreen" value="true" /><param name="src" value="http://screenr.com/Content/assets/screenr_1116090935.swf" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="345" src="http://screenr.com/Content/assets/screenr_1116090935.swf" allowfullscreen="true" flashvars="i=43322"></embed></object></p>
<h3>Part 5: Debugging with Netbeans and XDebug</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="i=43323" /><param name="allowFullScreen" value="true" /><param name="src" value="http://screenr.com/Content/assets/screenr_1116090935.swf" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="345" src="http://screenr.com/Content/assets/screenr_1116090935.swf" allowfullscreen="true" flashvars="i=43323"></embed></object></p>
<h3>Part 6: Wrapping up by showing a few features of debugging with xdebug in  Netbeans</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="i=43324" /><param name="allowFullScreen" value="true" /><param name="src" value="http://screenr.com/Content/assets/screenr_1116090935.swf" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="345" src="http://screenr.com/Content/assets/screenr_1116090935.swf" allowfullscreen="true" flashvars="i=43324"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://brettic.us/2009/11/07/developing-php-on-a-mac-with-netbeans/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 34/38 queries in 0.021 seconds using memcached

Served from: brettic.us @ 2012-05-20 01:33:07 -->
