If you use Eclipse PDT you probably noticed that there is no code completion in the view for helpers. The reason for that behavior is that Eclipse doesn’t know anything about CakePHP’s magic and so cannot provide code completion.
Now someone called “voidstate” posted a little trick in the CakePHP Google Group which makes it possible to get code completion in the view for helpers. For this purpose you have to create a PHP file somewhere in your project (it doesn’t matter where) with the following content:
<?php // stop page loading exit; // reference helpers so Eclipse provides code completion $ajax = new AjaxHelper(); $cache = new CacheHelper(); $form = new FormHelper(); $html = new HtmlHelper(); $javascript = new JavascriptHelper(); $number = new NumberHelper(); $session = new SessionHelper(); $text = new TextHelper(); $time = new TimeHelper(); ?>
As soon as the file is stored, you should have code completion. Thanks to voidstate for this trick!

I had been meaning to get to getting Komodo macros together to do this for some time and this spurred me:
http://traviscline.com/blog/2007/10/12/komodo-cakephp-view-macros/
I use Easy Eclipse for PHP. I created eclipse_helper.php, copied all of the above and pasted it in the file. Then placed the file in webroot folder, did a Project->Clean->Build (made sure .thtml files are opened by PHP editor).
However, I still couldn’t see code completion when I typed $html-> (and then ctrl + space).
?
Mandy – does your Eclipse project consist of just the apps folder?
@tclineks: Thanks for the link!
@Mandy: It is also possible that it is a PDT feature, and so doesn’t work with Easy Eclipse as it uses PHPEclipse.
It works for me. Thanks very much. Btw, my view files are *.ctp
@Jekin: Thanks for your comment!
[...] Code completion in views with Eclipse PDT – cakebaker Eclipse code completion in Views – Cake PHP | Google グループ タグ:cakephp, eclipse, PDT [...]
Just wondering I added this file, and now code completion works in the views, but like overall code completion is shaky. for example in the UsersController and User Model, I am not getting code completion for variables like $scaffolding, $name, $hasAndBelongsToMany, etc. For functions also i am not getting Cakephp code completion in Eclipse unless I type $this-> (otherwise i just see public, private, function, const, etc keywords). But i can hack around for now…
My workflow now is this:
For example, if I wanted a function in Model type $this->, find the function I want, like $this->beforeSave(), and convert that to function beforeSave(){} by deleting the rest.
If I need to figure out a variable like $hasAndBelongsToMany, I hit Control+Spacebar WITHIN any function, then move it outside into the class (it would be nice to do it from within the class and not the method in the class).
Anyone else have this issue? I mostly followed the Bakery tutorial.
@Arian: I have the same issues. But up to now I couldn’t figure out how to make code completion work in such situations (if it is even possible)…
[...] Code completion in views with Eclipse PDT [...]
[...] Code completion in views with Eclipse PDT – cakebaker Eclipse code completion in Views – Cake PHP | Google [...]
[...] Code completion in views with Eclipse PDT – cakebaker Code Completion for CakePHP in Eclipse | Mark Story Eclipse [...]
thanks for your help.