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.
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.
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 ![]()



September 4th, 2009 at 3:29 pm
Fantastic, Thanks!
September 4th, 2009 at 7:10 pm
CLEVER fellow !
I am most appreciative of your efforts.
MANY many thanks,
Mike
September 8th, 2009 at 6:05 am
Nice!
How to integrate with Zend Studio? Is the procedure also same?
September 9th, 2009 at 12:10 am
Very nice idea, Thanks a lot for sharing !
September 14th, 2009 at 2:54 pm
This is a really great tool and tutorial, thanks so much for sharing it!
September 25th, 2009 at 12:50 pm
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];”
October 4th, 2009 at 1:03 am
[...] http://rhasan.com/blog/2009/09/codeigniter-auto-complete-with-netbeans/ [...]
October 9th, 2009 at 6:04 am
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.
October 20th, 2009 at 4:39 am
I have been looking for something like this.
Thanks!
October 28th, 2009 at 2:51 am
amazing!
Ive been looking for this for a while
Thanks a lot
November 4th, 2009 at 3:13 pm
[...] Normally, this would mean changing all core Classes as well as your own. Fortunately Rakibul Hasan has shown us the light: By adding a prototype of your Model() and Controller() functions in [...]
November 17th, 2009 at 4:12 pm
Thank You: it worked!!! Very very very useful
November 22nd, 2009 at 6:47 pm
@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.
November 25th, 2009 at 8:55 am
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!
November 25th, 2009 at 6:03 pm
@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.
December 9th, 2009 at 11:38 pm
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
December 30th, 2009 at 2:10 pm
Many thanks. I’ve been waiting this for years. Will report it soon after I try it at home.
January 6th, 2010 at 3:10 pm
Can someone tell me if I can aply this code to Aptana/Eclipse? If so, can someone teach me ? Thanks.
January 19th, 2010 at 3:41 pm
@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.
January 19th, 2010 at 9:19 pm
Thanks a lot!! it really helped me a lot
February 19th, 2010 at 3:48 pm
thanks for the nice script.
February 19th, 2010 at 6:35 pm
@Wiwid, Yes you can use the modify the script according to your need and keep it there. Thanks for the heads up
March 11th, 2010 at 5:46 am
Thanks Rakib.It will be a very helpful feature in the development our PHP project as we are using CodeIgniter.
March 21st, 2010 at 2:24 am
Thanks for Sharing the Information, and keep Working like that!
March 28th, 2010 at 3:13 pm
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..
March 30th, 2010 at 3:34 pm
[...] CodeIgniter auto complete with Netbeans [...]
June 3rd, 2010 at 8:52 pm
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.
June 9th, 2010 at 2:39 pm
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.)
July 7th, 2010 at 10:16 am
Thank you very much for this nice post. Works like a charm!
July 28th, 2010 at 7:22 pm
Thanks for the excellent post!
August 12th, 2010 at 2:33 pm
AwEsOmE… Thank You. This was a great post