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

    1. New -> abbreviation: db
    2. Expanded text: `$this->db->`
    1. New -> abbreviation: `codei`
    2. 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
      */

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.

See also here and here

20 Responses to “Netbeans revisited: Code Completion for Code-igniter”

  1. Guido Says:

    Thanks man!

    This is really cool!

  2. DominixZ Says:

    This is very awesome article. Thank a lot

  3. programmer Says:

    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/

  4. d3ptzz Says:

    i’ve follow your tutorial, but why it didn’t work on my computer?

    please help me…

  5. d3ptzz Says:

    it just work on Controller?

    why in my Model it didn’t work

  6. d3ptzz Says:

    oh i’m sorry…its my stupidy…

    i’ve to restart it…

    just forget it:D

  7. Integrasi Code Igniter ke Netbeans - ..::d3ptzz personal blog::… Says:

    […] 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 […]

  8. Rakib Says:

    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

  9. Ji Zhang Says:

    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

  10. Renowned Media Says:

    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++).

  11. Netbeans revisited: Code Completion for Code-igniter « Huy Nguyen's Blog Says:

    […] 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 […]

  12. Vote for CodeIgniter Framework in Netbeans IDE - xBlurb Says:

    […] http://www.mybelovedphp.com/2009/01/23/netbeans-revisited-code-completion-for-code-igniter/ […]

  13. windows 7 driver Says:

    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 :)

  14. Stas Says:

    I use free PHP IDE Codelobster PHP Edition
    It has debugger and special plug-in for CodeIgniter framework.

  15. Alex Says:

    Thanks for sharing! Indeed this was very helpful for me…
    Regards,

  16. ipas Says:

    Good work. Thank you contribution krub.

  17. Paul Says:

    Thanks for this info, I’ve added this to all my PHP Templates in Netbeans and it works like a charm!

  18. programmer Says:

    @Paul You’re welcome. Netbeans is a fine IDE.

  19. Shahbaz Ali Says:

    Hi ,

    i am new in CI , it helps me alot.

    thanks :)

  20. Igor Says:

    It’s really helpfull, thanks for author!!!

Categories
Archives
Links