CodeIgniter auto complete with Netbeans Share

I had been longing for code completion for CodeIgniter with NetBeans for a long time. Finally got a very simple solution which I tested with NetBeans 6.7. It works for

  • All CodeIgniter system libraries
  • Own model functions
  • Own library functions
  • Helper functions

Basic Autocomplete :
To get autocomplete feature for basic CodeIgniter(1.7) functions ONLY just download this file(ci_autocomplete.php) and copy it in your netbeans project directory nbproject.

Basic CI autocomplete

Basic CI autocomplete

Advanced autocomplete:
For more advanced autocomplete feature like getting the list of model functions, your own library functions, you need to add

@property Your_Model $model_object_name

in the file ci_autocomplete.php( that you copied in nbproject). For example :

* @property Buyer_Model $buyer_model

Then in any controller if you write $this -> buyer_model -> …. the functions list will automatically popup.

Advanced autocomplete

Advanced autocomplete

Finally, to make every thing simple I just have written a simple script(autocomplete_script.php), can download from here, that will automatically traverse all the system libraries, your application libraries and models directory and list all class names. What you need is to

  • Run the script
  • Copy whole output
  • Paste it in a file and keep it in nbproject



Limitations:

  • If you extend a library like MY_DB_mysql_driver it does not work
  • You have to run my script(autocomplete_script.php autocomplete function) from a codeigniter controller
  • In my script(autocomplete_script.php) I assumed that model file name and class name same and all has _model as suffix(user_model, buyer_model) etc

Edit:
To make everything available for Models just need to add some properties after the Controller class in same fashion. I have updated my ci_autocomplete.php file accordingly. To see how all things work together you can see my autocomplete_all.php in the zip file.

For Helpers autocomplete:
You should automatically get the hint for helper functions available in your project. If you don’t get the hint then try tools -> options -> php -> Global Include Path -> add Folder -> your_system_folder.
Thats all !

Happy Coding with NetBeans and CodeIgniter :)

31 Responses to “CodeIgniter auto complete with Netbeans”

  1. Bretticus Says:

    Fantastic, Thanks!

  2. Mike Coughlin Says:

    CLEVER fellow !
    I am most appreciative of your efforts.

    MANY many thanks,
    Mike

  3. Sajjadul Robin Says:

    Nice!

    How to integrate with Zend Studio? Is the procedure also same?

  4. Mahmoud M. Abdel-Fattah Says:

    Very nice idea, Thanks a lot for sharing !

  5. Briandhall Says:

    This is a really great tool and tutorial, thanks so much for sharing it!

  6. Erki Says:

    Nice work. Thanks!
    I do get some errors though.
    I don’t have underscores in all my Model names so I get errors on the line “$last_part = $file_parts[1];”

  7. Heartshare » Blog Archive » CodeIgniter auto complete with Netbeans Says:

    [...] http://rhasan.com/blog/2009/09/codeigniter-auto-complete-with-netbeans/ [...]

  8. Marcus Says:

    wow That is greate work you have done! Thanks very much.

    is there any way auto complete could be done on Aptana - Eclipse or Dreamweaver? or even zend?

    Thanks again.

  9. Alex Says:

    I have been looking for something like this.

    Thanks!

  10. Nicolas Says:

    amazing!
    Ive been looking for this for a while
    Thanks a lot

  11. Netbeans and PHP Frameworks on signalkraft Says:

    [...] Nor­mally, this would mean chang­ing all core Classes as well as your own. For­tu­nately Rak­ibul Hasan has shown us the light: By adding a pro­to­type of your Model() and Controller() func­tions in [...]

  12. Bruno Says:

    Thank You: it worked!!! Very very very useful

  13. rakib Says:

    @Robin & Marcus : I haven’t tried with other IDEs. But if you find any way to get them working, you are welcome to write down the way here.

    @Erki : I follow a convention to name all the models ended with _Model. So that it does not confuse when using.

    @Rim : By default nbproject folder is located in the same directory as system folder.

  14. Joebar Says:

    I’m new to CI and netbeans so sorry for the stupid question: How do you run the autocomplete_script.php file?
    does it have to be called from a controller?

    I managed to run it independently but it just returns a blank page. Maybe i’m missing something here.

    Thanks for your help!

  15. rakib Says:

    @Joebar, yes, script have to run from a controller.
    You should get output. if u getting blank page then make sure u have followed the steps carefully.

  16. mm Says:

    Doesn’t work for me in case of using models. I try to write: $this->my_model->.. and it doesn’t show the autocomplete list, I have this model in the ci_autocomplete in nbproject I generated using Your code.. other functions work, only the model functions doesn;t appear :(

  17. sangprabo Says:

    Many thanks. I’ve been waiting this for years. Will report it soon after I try it at home.

  18. jonas Says:

    Can someone tell me if I can aply this code to Aptana/Eclipse? If so, can someone teach me ? Thanks.

  19. Wiwid Says:

    @rakib
    I need your permission to store the modified autocomplete_script.php on my host.

    @mm
    Looks like rakib forgot to add ‘Model ()’ on the end of the code. Please download at http://www.wiwid.org/autocomplete.zip. Extract and copy autocomplete.php to your ‘application/controller’ directory. Run it as http://example.com/autocomplete. Copy and replace the code to old ci_autocomplete.php.

    It should be done, and you can see autocomplete of your model.

  20. Batou Says:

    Thanks a lot!! it really helped me a lot

  21. mahfuz05 Says:

    thanks for the nice script.

  22. rakib Says:

    @Wiwid, Yes you can use the modify the script according to your need and keep it there. Thanks for the heads up :)

  23. batu Says:

    Thanks Rakib.It will be a very helpful feature in the development our PHP project as we are using CodeIgniter.

  24. Natürliche Potenzmittel Says:

    Thanks for Sharing the Information, and keep Working like that!

  25. Mendrinos Says:

    This is a good example, but it is still a workaround…

    I mean, IDEs should start look more seriously support for frameworks out of the box..

  26. Enlaces rápidos (30-03-2010) | Sentido Web Says:

    [...] CodeIgniter auto complete with Netbeans [...]

  27. fstart Says:

    i was looking for this,, for quite some time now.. i found something like it.. but even limited than the basic setting.. this is a time saver.. thanks dude.

  28. Tomas Mysik Says:

    Well, this is apparently a bug in CodeIgniter PHPDoc documentation - if they provide correct PHPDoc for their classes (as your scripts do) then it will work as expected.
    (This is why Symfony or Zend Frameworks work in NetBeans automatically.)

  29. Box He Says:

    Thank you very much for this nice post. Works like a charm! :D

  30. Kris Says:

    Thanks for the excellent post!

  31. Lokky Says:

    AwEsOmE… Thank You. This was a great post

Leave a Reply