CodeIgniter Autocomplete

Codeigniter is a great framework for php . It is simple and already helps lot of people to write faster code. The documentation is very good with examples for all the classes – functions.

But (there is always a but…!) in eclipse we used to have our own classes and when we write the “magic arrow” -> we are waiting to have a dropdown list with the functions/variables that the class have .

In Codeigniter till now we write for example $this->session-> … and then we go to the codeigiter website just to see what was the name of the function .

For that reason I created a fake Controller. This is only a fake Controller and it used ONLY for the autocomplete. You can copy paste it WHEREVER you like in the project (because is fake).

Ok lets see it how it works .

1st Step

Download the zip file :

Download the zip file for CI 2.X and CI 3.X (recommended)

or

Download the zip file for CI 1.7.x

or

Download the latest development edition from github repository: https://github.com/scoumbourdis/codeigniter-autocomplete

2nd Step

Copy it somewhere in your project (I’ve copy it into libraries in a folder named fake)

3rd Step

Start typing in your Controller :-). That’s it. Pretty easy right? Below there are some images to show what you are be able to do.

It works fine in eclipse,netbeans and Aptana.
 

Next post →

36 Comments

  1. Hello Marco and thank you for your post. Make sure:
    1. that you work in eclipe.
    2. If it doesn't work refresh your project and then try again.
    3. If again it doesn't work (that is really rare!!!) go to the system->libraries->Controller right click ->Built Path and then go to Exclude (as I show you in the image)
    4. If again it doesn't work make sure your class extends Controller for example:

    class Welcome extends Controller {

    function Welcome()
    {
    parent::Controller();
    }

    function index()
    {
    $this->load->view('welcome_message');
    }
    }

    /* End of file welcome.php */
    /* Location: ./system/application/controllers/welcome.php */

     
  2. Not work 🙁

     
  3. if you're using CI 2.0 just rename Controller to CI_Controller and autocomplete will work

     
  4. web_and_development

    Thanks Andre I didn't know that

     
  5. hi it doesn't work in my project. I make points:
    1. that you work in eclipe.
    2. If it doesn't work refresh your project and then try again.
    but the 3 i cant find. I worh with CI 2.0 my controler.php is in system/core/controler.pho when I Right mouse click i have Built Path but it shows sub menu Configure bulid path… and then What would I do?

     
  6. You can download the files for CI 2.0 from this url – http://www.web-and-development.com/downloads/fakeController_CI_2.0.zip. I just updated my post so you can download it from there. Hope it helps

     
  7. web_and_development

    You can download the files for CI 2.0 from this url – http://www.web-and-development.com/downloads/fakeController_CI_2.0.zip. I just updated my post so you can download it from there. Hope it helps

     
  8. This also works for Netbeans 🙂
    thnx for sharing

     
  9. ofuenzalida

    netbeans??'

     
  10. web_and_development

    Yeap NetBeans for PHP

     
  11. Thank you!

     
  12. Decroffie

    Thanks for the library idea.

     
  13. Thanks a lot. It is very helpful. But it doesn’t work in models. Probably people who say not work tried in a model. To make work in a model;
    + Copy fake_controller.php and paste same directory.
    + Rename it fake_model.php
    + Rename class name from CI_Controllers to CI_Model. 

     
  14. that’s a nice work! thank you!

     
  15. I’m going to add this in all my projects

    ciao!

     
  16. Good Job!

     
  17. Great, thanks a lot!

     
  18. Great post, thanks!

    The autocompletion now works, but I still can’t get “Open Declaration F3” to work… even on methods that show up in the autocompletion.  Do you have any suggestions?

    Also, when I load models

    $this -> load -> model(‘my_model’);Autocompletion doesn’t show up $this -> my_model  (or anything that is part of my_model with an extra ->).  Again, any pointers you might have greatly appreciated!

     
  19. mehmet soylu

    if you using HMVC thirdy_party system, you should change fake controller class name with probably “MX_controller”. 

    Thank you for idea.

     
  20. It works fine but is there a systematic way to do so, that works with all (or most) other frameworks? I have my custom MVC framework which netbeans understands well but eclipse is dead for that framework too.
    The method you have used is just like pushing eclipse to include the specified things. It is still not able to load the libraries on its own.

     
  21. hi i download this but can not extract it… can you plz help me..

    thanks

     
  22. web_and_development

    Try to download it from my github repository

    https://github.com/scoumbourdis/codeigniter-autocomplete/archive/master.zip

     
  23. engrmudasirmalik

    this is kind of very awesome 🙂

     
  24. Stefan Rogin

    Great job, thanks! Eclipse found 3 duplicate entries in the file ($image_lib,$form_validation,$lang) is there any reason for them ?

     
  25. web_and_development

    Yes you are right. I just forgot to renew the zip file. Now it looks better 😉

    Thanks

     
  26. Carnevalli

    It works fine!! Thanks for sharing

     
  27. Максаров Михаил

    CI_Router is missing

     
  28. web_and_development

    Even though it is at the $this->router , it is not anywhere documented at the codeigniter user guide so I am not using it.

     
  29. Vipin Kr. Singh

    Could you please explain the logic behind it, I mean how it works. I want to make it work for WordPress.

     
  30. Firas Abd Alrahman

    eclipse detect all classes even if you does not include them with “include” function

     
  31. You should provide by demo and tutorial, it help new bie to understand it !

     
  32. I prefer to use Codelobster for CodeIgniter autocomplete: http://codelobster.com/codeigniter.html

     
  33. Thanks for taking the time to write this. I am going to use it for some projects in the future. Brian

     
  34. Hi, Thanks.
    Please update it for codeigniter 3.X and 4.X
    Very very thank you.

     
  35. web_and_development

    It works just fine with 3.X. I will also check it from 4.X and I will update the post 🙂

     
  36. Thanks a lot!

     

Leave a Reply