CodeIgniter version 3 – 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 →

38 Comments

  1. Not work 🙁

    • 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. if you're using CI 2.0 just rename Controller to CI_Controller and autocomplete will work

  3. 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?

  4. This also works for Netbeans 🙂
    thnx for sharing

  5. ofuenzalida

    netbeans??'

  6. web_and_development

    Yeap NetBeans for PHP

  7. Thank you!

  8. Decroffie

    Thanks for the library idea.

  9. 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. 

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

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

    ciao!

  12. Good Job!

  13. Great, thanks a lot!

  14. 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!

  15. mehmet soylu

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

    Thank you for idea.

  16. 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.

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

    thanks

  18. engrmudasirmalik

    this is kind of very awesome 🙂

  19. Stefan Rogin

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

    • web_and_development

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

      Thanks

  20. Carnevalli

    It works fine!! Thanks for sharing

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

    CI_Router is missing

    • 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.

  22. Vipin Kr. Singh

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

    • Firas Abd Alrahman

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

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

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

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

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

    • web_and_development

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

  27. Thanks a lot!

  28. Robert

    Why not one for Sublime Text editor? 🙂