Netbeans: Code Completion for the Kohana Framework
In some earlier posts I’ve described ways to get Netbeans code completion working for CodeIgniter. In this post I will show you how to do the same for Kohana.
Kohana is originally a PHP-5 only fork of CodeIgniter, but it has developed into much more. Now all code has been rewritten, so only the framework in concept is based on CodeIgniter. It has nice ORM, AUTH and Cache modules.
It’s easy to convert and actually I prefer Kohana, it’s more intuitive and extensible. The only drawback: Kohana needs PHP 5.2+, where CI can be used with PHP 4.
Kohana uses the PHP class autoload feature, no need to include class files manually, PHP will lookup the file on the included path automatically at the moment the class is mentioned.
So when you write.
$this->db = New Database
The Database class declaration file will be loaded by PHP automatically. This way of lading classes is also understandable for the auto completion parser of Netbeans.
This is in contrast to CodeIgniter, because there classes are loaded like:
$this->load->library('validation')
To achieve code completion for CodeIgniter in Netbeans we have to manually insert comments to help the auto completion parser map properties to classes:
* @property CI_DB_active_record $db
That’s not the case in Kohana, but there is another problem. Kohana uses Class suffixes. The classes are declared like Database_Core, but called like Database (without the _Core).
To evade that we grap to the netbeans_ci_code_autocompletion helper file trick. But here we don’t write the property in comments, we simple do this:
Class Database extends Database_Core{}
etc
You can see the discussion on which this post is based in the Kohana forum. There is even a script that will generate the file automatically, so it will do extensions aswell. Works for Zend, Netbeans and Eclipse.
You can find the script here:
http://www.mapledesign.co.uk/code/kohana-zend-autocomplete/
There is a nasty flaw though on the website, they mixed up names. The script should be activated by:
http://yoursite/zend_ide
And it will create a zend_autocomplete.php file in the cache directory. You can move that to the nbproject folder if you want.
July 22nd, 2009 at 12:59 pm
I am a great NetBeans fan and the IDE have been working really well with DooPHP framework with all the autocomplete and code hinting. Have a look if you have the time
Kudos to Netbeans!
September 7th, 2009 at 6:38 am
??? ? ????. ???????? ? ?????????? ???.
http://www.mybelovedphp.com – ??????????? ??? ? ???????? )
October 4th, 2009 at 3:03 am
[…] http://www.mybelovedphp.com/2009/01/27/netbeans-code-completion-for-the-kohana-framework/ […]
October 22nd, 2009 at 8:57 pm
However, we cannot afford to be complacent. ,
February 22nd, 2010 at 10:47 am
nice article, thanks
January 28th, 2011 at 12:43 pm
;-~ I am really thankful to this topic because it really gives up to date information ‘,,
January 30th, 2011 at 12:05 am
“:” I am really thankful to this topic because it really gives useful information -:’
March 26th, 2011 at 8:24 pm
Hi,
FYI – from your tip – i wrote a CI @property generator
code available on CI forum : http://codeigniter.com/forums/viewthread/184716/
September 7th, 2011 at 9:34 pm
Hey all, I discovered your site by using Yahoo even while hunting for a very similar issue, your site came out, it appears to be great. I’ve bookmarked it within my google book mark
March 26th, 2012 at 5:45 pm
Thank you!! I was looking for Netbeans+codeigniter tutorial for a long time!! But How about Joomla support?
May 28th, 2012 at 12:11 pm
post 2 host…
[…]My Beloved PHP » Blog Archive » Netbeans: Code Completion for the Kohana Framework[…]…