<?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>Farrworks &#187; Banter</title>
	<atom:link href="http://farrworks.com/tag/banter/feed/" rel="self" type="application/rss+xml" />
	<link>http://farrworks.com</link>
	<description>Technology, Work, Life, Play, and everything else in between the ears of an Ian...</description>
	<lastBuildDate>Fri, 26 Feb 2010 22:17:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Tale of PHP IDE&#8217;s</title>
		<link>http://farrworks.com/2009/02/a-tale-of-php-ides/</link>
		<comments>http://farrworks.com/2009/02/a-tale-of-php-ides/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 06:22:23 +0000</pubDate>
		<dc:creator>Ian Farr</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tech Talk]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Banter]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://farrworks.com/?p=160</guid>
		<description><![CDATA[I have been an Ecipse PDT user for the last couple of years, and while I have gotten it to &#8220;work&#8221; with CakePHP, I have always found it a messy solution, as you have to &#8220;hack&#8221; up your sources pretty good in order for Eclipse to understand the CakePHP world.
While this does work, it is [...]]]></description>
			<content:encoded><![CDATA[<p>I have been an Ecipse PDT user for the last couple of years, and while I have gotten it to &#8220;work&#8221; with CakePHP, I have always found it a messy solution, as you have to &#8220;hack&#8221; up your sources pretty good in order for Eclipse to understand the CakePHP world.</p>
<p>While this does work, it is not a pretty solution, is not easily manageable, and leaves a bad taste in my mouth, so I figured that there must be a better way&#8230;and there is with <a href="http://www.netbeans.org">Netbeans </a>!</p>
<p><span id="more-160"></span></p>
<p>So, off I go again seeing if there are any new developments in the PHP IDE arena these last 6 months or so, and what do I find&#8230;Netbeans for PHP. Because I have tried almost every other PHP IDE on the planet, but have never tried <a href="http://www.netbeans.org">Netbeans </a>(since it never really had good PHP support until recently)&#8230;I decide that this will be the week.</p>
<p>As I am downloading and installing the thing, I start browsing around to see if there are any tips for CakePHP integration. About 30 seconds later,  I find something &#8211; and it looks promising.</p>
<p>So, I load up my usual test project, make some modifications to the source&#8217;s comments so that Netbeans understands the Cake world, and what can I say &#8211; I was really, really, really floored. This worked MUCH better then anything I had ever used before &#8211; much, much better then I ever had with Eclipse, in a much cleaner, and more manageable way.</p>
<p>Before I start talking too much about Netbeans, let me just cover the issues that I had with Eclipse&#8217;s code completion with CakePHP. To get Eclipse to understand that $this->Model in your controller was a model, you had to add something like the following to your controller:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @var ModelName<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$ModelName</span><span style="color: #339933;">;</span></div></div>
<p>Now, this doesn&#8217;t seem like a big deal at first, but once you realize that you have to do this for every component, helper, model that your controller uses, it gets a little nasty. Now, let&#8217;s just say that our $ModelName model has multiple relationships with other models. The CakePHP way is to access them as such:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ModelName</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">OtherModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>So, Eclipse knows about ModelName, and we have code completion for that. But it knows nothing about ModelName->OtherModel&#8230;no code completion, we are stuck. So off we go again adding more comment blocks to try and manage Eclipse.</p>
<p>Now, again, you multiply this by all of your application models, and you end up with a mess pretty quickly. This even gets worse.</p>
<p>For components, cakePHP uses a component array to define which components your controller will use. Let&#8217;s say that I have some core components that I will use in every controller. Instead of loading them up manually in each and every controller, it makes more sense to load them up in my AppController, where all the other controllers are derived from.</p>
<p>So, in your AppController you start adding the Eclipse @var code blocks for all the components so that Eclipse can figure out the code completion, and it works great&#8230; in your AppController at least. Next you open one of your other controllers and start typing $this->ComponentName->&#8230;.and nothing. No code completion again!! Eclipse, for whatever reason, can&#8217;t code complete an inherited @var comment block. Maybe I just did something wrong, but this never really worked well at all for me, at least not consistently.</p>
<p>Ok, so how do you get it working&#8230;well, you have to include the stupid @var comment blocks in each and every controller that you want code completion for&#8230;this is insane and is a complete mess.</p>
<p>You do this for all your Model&#8217;s, all the Model relationships, all the components, and then count how many lines of code in your entire project that was added just to make eclipse&#8217;s code completion work&#8230;it&#8217;s a lot. A lot of code, a lot of redundancy, and when you have to change things, it&#8217;s a lot of new code to add &#8211; simply stated, it&#8217;s a lot. Too much if you ask me.</p>
<p>Ok, so now I have talked about how all the Eclipse hacks are messy, how does Netbeans compare?</p>
<p>At first Netbeans seems to use a very similar method for helping it understand CakePHP&#8217;s world. You use @property javadoc comments in the codeblocks just before the class&#8217;s declaration, like so:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @property ModelName $ModelName<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">Class</span> ModelNamesController <span style="color: #000000; font-weight: bold;">extends</span> AppController <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></div></div>
<p>So, now you have a single @property javadoc comment to tell Netbeans that $this->ModelName refers to the ModelName model for that controller, and code completion works great. So far so good. </p>
<p>At least this is just a single comment line, and I don&#8217;t need to declare a useless variable like I have to do with Eclipse. With Eclipse, I would have a comment block consisting of at least 1 line, but possibly 3 lines (/**, * @var, */) depending on the project&#8217;s source code formating policy, and then the actual useless var $name line. That&#8217;s either 2 or 4 lines of code to do Netbeans&#8217; 1 line of code. That&#8217;s at least a 50% improvement, not bad at all.</p>
<p>What about $this->ModelName->OtherModel-> code completion support? How do I get that to work?</p>
<p>Well, this is where Netbeans really starts to show it&#8217;s power. In the comment block that is just before your Model declaration, just add  the same @property for each model that it has a relationship with. Example:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @property OtherModel $OtherModel<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">class</span> ModelName <span style="color: #000000; font-weight: bold;">extends</span> AppModel <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></div></div>
<p>That&#8217;s it. Again, a single line of code for each relationship that this model has. The best thing about this is that Netbeans, unlike Eclipse, properly understands inheritance when it comes to the @property javadoc comments. As soon as you do this in your Models, all of a sudden, in your controller, $this->MyModel->OtherModel-> has code completion&#8230;awesome. This never worked well with Eclipse, and I just got rid of a TON of code duplication all over the place with @var comment blocks to try and get Eclipse to work. Now I am really happy, as this is much more then a 50% improvement&#8230;</p>
<p>Now, what about components? Well, components are exactly the same thing. In my AppController&#8217;s comment block that is right above it&#8217;s class declaration (for all the common components that every controller uses), you just add an &#8216;@property ComponentNameComponent $ComponentName&#8217; line for every component that you want to use. Again, because Netbeans understands inheritance with these @property comments, they work in every controller &#8211; immediately. Wow.</p>
<p>Ok &#8211; now I am in heaven. I can get rid of all of these silly @var&#8217;s all over the place, which already cleans up the code a lot, and have a much cleaner, and controllable method of telling Netbeans about the CakePHP world.</p>
<p>At this point, I wanted to see how helpers in the views could get code completion, and this works pretty much exactly like Eclipse, so they are the same when it comes to helper code completion support. All you need is a file in a include directory, or somewhere in the &#8220;project&#8221; that has something like:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//this file does nothing, it's just so netbeans can code assist any of these</span><br />
<span style="color: #666666; font-style: italic;">//objects in all our views</span><br />
<br />
<span style="color: #000088;">$ajax</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AjaxHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FormHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HtmlHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$javascript</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JavascriptHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$number</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NumberHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SessionHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TimeHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$pagination</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PaginationHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$rss</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RssHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<span style="color: #000088;">$number</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NumberHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$paginator</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PaginatorHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>As long as Netbeans (or eclipse for that matter), can see this file, you get code completion for helpers in all your views. This is an OK work around, and I have no issues with this method.</p>
<p>Netbeans also has some really nice features out of the box:</p>
<ul>
<li>awesome refactoring support &#8211; very cool stuff (look into Ctrl-R)</li>
<li>searching with very cool &#8220;diff&#8221; like displays for all matches in the scrollbar area</li>
<li>great CSS code completion</li>
<li>awesome javascript support</li>
<li>support for multiple language code completion in a single file (ex: css -> javascript -> php)</li>
</ul>
<p>You add all this up, and I think that it will take a major problem Netbeans to get me back over to the Eclipse camp. </p>
<p>It is at least as good as Eclipse in most areas, and has a much cleaner and easier way of setting up code completion for PHP frameworks. It is also a no hastle-everything just works- installation, unlike Eclipse where you have to download a bunch of add-ons after you get it so that it can do the things you want&#8230;that&#8217;s if you remember which update site was needed to install the add-on&#8230;..that&#8217;s also a mess &#8211; but let&#8217;s not go there right now <img src='http://farrworks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>The Netbeans add-on&#8217;s are more along the lines of Jedit, where you have a single section in Netbeans to view all &#8220;stable&#8221; add-ons, and you can install them within Netbeans. No browsing around for a while trying to find something and figuring out how to install it like you have to with Eclipse. You can also download alpha/beta add-ons from the netbeans.org site easily, which then you can install them in netbeans with a couple of clicks. I think this is a much better way of handling add-ons.</p>
<p>So &#8211; I think I am a Netbeans convert&#8230;if you haven&#8217;t used it before, I think it deserves a shot.</p>
<p>If you have had similar (or dissimilar) experiences with Netbeans, I would love to hear your comments <img src='http://farrworks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://farrworks.com/2009/02/a-tale-of-php-ides/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
