Netbeans revisited: Code Completion for Code-igniter
Some software you like, you start working with it, and you feel like it’s made for you. Everyday you discover a little bit more of all the hidden powers. That’s the good thing about open source, there is so much power that has yet to be discovered. Most commercial software claim a lot of features in their marketing brochures and disappoint enormously in the end when you start working.
Netbeans 6.5 is good software, out of the box it offers code completion and validation for php, html, css, javascript including jquery, mootools etc.
Code Igniter is a rapid development framework for PHP, it’s a flexible MVC-like system. Netbeans let you easily implements CodeIgniter powers, by offering code completion for CodeIgniter’s native Active record classes, libraries and helpers functions.
You need to set it up though, and here we will explain how:
The first step is only neccesary if you have moved the system folder out of the Netbeans project source folder that contains the application folder, in case of a multi site set up or something.
Add the CodeIgniter System folder to the Netbeans Global Include Path:
Tools>Options>PHP>Add folder to Global Include Path
This will give code completion for the helper functions and some more, but not for the Active record or database functions in a controller.
$this->db->...
To achieve more power, add this to your controller:
/**
* @property CI_Loader $load
* @property CI_Form_validation $form_validation
* @property CI_Input $input
* @property CI_Email $email
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
*/
class Stylist extends Controller
Now you can type
$this->db->...
or
$this->dbforge->...
And you will get all available functions offered. Wow!
To make it really easy, add this to Tools->Options->Editor->Code Templates
-
- New -> abbreviation:
db
- Expanded text: `
$this->db->
`
- New -> abbreviation:
-
- New -> abbreviation:
`codei`
- Expanded text: `
/**
* @property CI_Loader $load
* @property CI_Form_validation $form_validation
* @property CI_Input $input
* @property CI_Email $email
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
*/
- New -> abbreviation:
Now you can easily insert the Codeigniter code just above your controller, by typing `codei` and TAB
or db TAB for $this->db->
That rocks, doesn`t it.
January 24th, 2009 at 4:35 pm
Thanks man!
This is really cool!
January 24th, 2009 at 5:35 pm
This is very awesome article. Thank a lot
January 27th, 2009 at 2:43 pm
Thx, for your comments, I’ve written an even easier solution in the follow-up:
http://www.mybelovedphp.com/2009/01/27/netbeans-revisited-code-completion-for-code-igniter-ii/
February 2nd, 2009 at 6:29 am
i’ve follow your tutorial, but why it didn’t work on my computer?
please help me…
February 2nd, 2009 at 6:34 am
it just work on Controller?
why in my Model it didn’t work
February 2nd, 2009 at 6:37 am
oh i’m sorry…its my stupidy…
i’ve to restart it…
just forget it:D
February 2nd, 2009 at 9:21 am
[…] Netbeans+CI. Bukankah Netbeans juga sudah support PHP? Searchinglah saya di google. Dan menemukan MyBelovedPHP. Disana ada tutorialnya. Saya akan postingkan ulang disini dengan bahasa Indonesia. Mari kita […]
September 1st, 2009 at 6:53 am
Thanx for awesome post. Your tips work for all controller, Models. But I am facing a problem. If my project is already open $this->db->… etc does not work. if i restart the netbeans then it works. now after the restart, in another file if i write the
@property CI_Loader $load etc
code it does not work. I have to restart netbeans again to get it working 🙁
So I have to restart each time i write the properties in a new file….Can you please give me a solution. I am using netbeans 6.5
September 8th, 2009 at 12:01 pm
To Pakib
i think the best way to do is using template
as author mentioned
“2. 1New -> abbreviation: ”
which you onlyneed to edit template system
October 29th, 2009 at 10:32 pm
Very useful, thanks.
Another necessary change is to set up the duplicate line command to Ctrl+D instead of Ctrl+Shift+Down, I use the command so much that I need a shortcut (This was the default configuration of Notepad++).
April 14th, 2010 at 8:16 am
[…] I found that it does not. Fortunately, there is a tip I found very useful and worth bookmarking http://www.mybelovedphp.com/2009/01/23/netbeans-revisited-code-completion-for-code-igniter/ Categories: Bookmarks, PHP, Programming Comments (0) Trackbacks (0) Leave a comment […]
May 12th, 2010 at 8:22 am
[…] http://www.mybelovedphp.com/2009/01/23/netbeans-revisited-code-completion-for-code-igniter/ […]
May 18th, 2010 at 10:40 am
Great info and right to the point. I don’t know if this is truly the best place to ask but do you guys have any ideea where to employ some professional writers? Thx 🙂
August 9th, 2010 at 9:49 am
I use free PHP IDE Codelobster PHP Edition
It has debugger and special plug-in for CodeIgniter framework.
January 31st, 2011 at 1:06 pm
Thanks for sharing! Indeed this was very helpful for me…
Regards,
February 6th, 2011 at 8:07 am
Good work. Thank you contribution krub.
February 7th, 2011 at 2:53 am
Thanks for this info, I’ve added this to all my PHP Templates in Netbeans and it works like a charm!
March 4th, 2011 at 11:38 am
@Paul You’re welcome. Netbeans is a fine IDE.
September 12th, 2011 at 7:31 am
Hi ,
i am new in CI , it helps me alot.
thanks 🙂
December 25th, 2011 at 11:05 pm
It’s really helpfull, thanks for author!!!