Netbeans revisited: Code Completion for Code-igniter II

In an earlier post I described a way to achieve PHP code completion in Netbeans for the CodeIgniter framework. That way consisted of inserting property comments – which functioned as a helper for Netbeans to interprete the use – in every user application controller. This post will describe an even easier way, but first some comments about the earlier post.

I showed some ways to automate the inserting of the comments, although writing phpDocumentor comments in Netbeans is supported natively. Just type /** and completion will be available like explained here.

It’s a good custom to write comments in phpDoc style, it will help users to understand your coding, and it will offer an extremely easy way to publish documentation about your programs. Read here more about phpDOC.

On more remark, I wrote to include the CodeIgniter path in the Netbeans Global Include Path, it’s definitely better to do it on a project basis, so include it in the PHP Include Path in the Project Properties. Otherwise you will have CodeIgniter completion on projects that don’t use CI. 🙂

Now were getting to the core of this post. Probably the easiest way to achieve code completion is to put a file in the source path of Netbeans, but out of the CodeIgniter application or systems paths, let’s say a file called `netbeans_ci_code_completion.php`, but you can give it any name you want.

Make a text file with this content:
< ? /** * @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 * @property CI_Table $table * @property CI_Session $session * @property CI_FTP $ftp * .... */ Class Controller { } ?>

It doens’t matter how you call it, as long it has a php extension and is seen by Netbeans but not CodeIgniter. You can save it in a folder called temp, or even in the nbproject (netbeans project folder) folder. I worked for me, and I’ve haven’t noticed any drawbacks yet.

For most of my projects I have this project folder structure:


Putting it in the nbproject folder has the advantage that the file will not by copied to the server automatically, because that folder is already marked to be excluded in the synchronization settings.


  1. Hi,

    Have you heard of a CodeIgniter project type, or file types for CI files? That would be another way to get the comments pre-stamped into CI PHP files… I haven’t found any, but perhaps you have?

  2. @Steve. No, that’s a thing a like about Kohana. Kohana::list_files. I would make the step to Kohana iif all servers were > php 5.2.

  3. Is it OK if I link to this post and the Kohana post from the NetBeans PHP doc learning trail?

  4. Very cool. Thanks. In your project folder structure, is your application folder the same one from the codeigniter install?

  5. @sean
    Yes I’ve placed the system folder out of the webroot for security reasons and to use it multisite.

  6. I’ve got this in a template file called CI Controller, and a CI Model file with similar…

    if (!defined(‘BASEPATH’)) exit(‘No direct script access allowed.’);

    * @property CI_Loader $load
    * @property CI_Form_validation $form_validation
    * @property CI_Input $input
    * @property CI_Email $email

    class XXX extends MY_Controller {

    public function __construct()

    public function index()


    } // EOC

    /* end of file ./application/controllers/XXX.php */

  7. You should know that code completion will not work if nb project structure looks like:


    cc works only if application folder is first-level folder in project

  8. maybe I did something wrong, but I originally had my structure like this:


    This was so that CISystem could be used across multiple hosted sites, and each website would be a netbeans project, so it had a nbproject folder in it, which is where I placed the file you suggested above.

    What I noticed is that I didn’t get proper full on code completion with this structure until I put the files in CISystem folder back inside the project.

    So I either had two choices, one project file for multiple websites, or move the CI system folder back inside my website project folder.

    Unless I’ve done something wrong? 🙂

  9. actually, I have another question you might be able to answer!

    I had a number of classes and collection classes in an old project, that are mostly object structures, with getter/setter functions, which I’d created so that I could get lovely netbeans code completion on my objects while looping through things and so on. It just felt the right thing to do.

    However, as i’m now trying to build a project using CI, I want to use this lot in a new library for CI, but I want to be able to access this library and get Code Completion.



    actually, going one step further, can a library hold multiple classes? e.g. I load “mylibrary” and then I can get access to:


    or perhaps more likely:

    $myObject = $this->mylibrary->someClass();

    so that I can then do:



    I think I’m going to have to pose this question in the forum but it’s down at the moment, grrr.

  10. @Andrew
    I do the same as you. One core CI system directory for multiple sites:

    1 easy updating
    2 better performance (file-caching)

    Don’t forget to include the CI system directory to the PHP include path at the Project Properties.

    That should work!

    @Andrey probably answered your question as well.

  11. I’ve tried to follow the instructions above and the code competition doesn’t seem to be working for me.

    So far I’ve added my system folder to the include path and created a directory temp with a folder inside called “netbeans_ci_autocomplete.php”. Is there something I’m missing here?

  12. @Mike,
    You have to restart netbeans EACH TIME(I guess) you add ‘@properties ….’ code snippet in any controller/model.

  13. Hi,
    It works only with controller. How can I get it working with model. Because I have to use $this -> db …. in all model… Plz give a solution

  14. @Mike,
    Sorry, I have installed netbeans 6.7 and i don’t need to restart at all to get it working. But with netbeans 6.5 I had to do it. Weird though.

  15. using this structure
    — application (your ci application)
    — system (ci system)
    — www (css,js and index.php)
    set source folder and project folder as home
    set web root as the www folder
    code completion etc works – no need for hooks etc.
    to debug just click debug let debug attach then remove ?xdebug string and continue as usual – (know an automatic fix?)

  16. If it is not working with CodeIgniter 2.0 for you, this may help:
    I spent about 2 hours banging my head until I realized 2 things that need to be changed from the snippet:
    1. the ‘php’ was stripped from the opening tag
    2. (for CI 2.0 only… I think) change the class declaration from Controller to CI_Controller.
    Hopefully that helps someone out!

  17. Hi to everybody,

    I’m new to CI, but I’ve got several sites/web solutions working in php. I use NetBeans 7.0.1 for coding over XAMPP.

    I’m trying to adapt CI and I’m not sure where to place the folders it needs. CI comes with three folders: user_guide, application and system.
    I know “application” should be copied inside every project using CI as the author suggested above.
    Nothing to say about “user_guide”.
    But, where should I put “system”? in htdocs? in every project-folder as “application”?

    Thanks a lot for your reply in advance.

  18. Hi Mawey,
    I put the system folder outside the doc-root and have all websites using that same system folder. In the main index.php file:
    $system_path = ‘/home/../../../system’;
    you set the path to the system folder.
    It is then very easy to update the core of CI for all users at the same time.

  19. Pingback: PHP Scripts
  20. Pingback: Indigovara
  21. Pingback: scripts, themes
  22. i put the file in the C:/Program Files/NetBeans/ directory but code completion still doesn’t work… i mean when i type $this->load-> for example nothing shows even when i press ctrl + space…

Comments are closed.