NuSphere PhpED code completion for CodeIgniter Framework

NuSphere PhpED is PHP IDE of my choice since when I’m in college while CodeIgniter is my PHP Framework of choice because of it’s simplicity, extensibility and documentation. Creating website using CodeIgniter Framework on PhpED is quite a hassle because of non-working code completion for CodeIgniter’s MVC. PhpED won’t show you a list of code suggestion after you type (for example): $this->load->

phped 7 logo

this tips is tested on PhpED version 7.0 build 7044 and CodeIgniter 2.1.2

Well, that’s only until today. I solve the code completion after lurking on CodeIgniter’s and found Autocomplete package. The package claim to work on Netbeans and ZendStudio so I give it a try on PhpED and it does work.

This is how you do it:

Create autocomplete.php and save it on your application/config/ folder

codeigniter autocomplete in phped

This is how your application/config/ now look like

autocomplete.php structure is like this:

  1. declaration of CodeIgniter’s base class as PHPDoc virtual @property (those base class is on ‘system’ folder)
  2. declaration of your ‘models’ also as PHPDoc virtual @property. As example, I have ‘cds‘ model on my test
  3. then your own ‘libraries’ class as PHPDoc virtual @property. As example, I use our ‘pdf’ (based on pdf-php/ezpdf), ‘excel’ (based on PHPExcel) and ‘word’ (based on PHPWord) libraries
  4. and the rest .. (just follow the code.. I’ll keep it simple)


this is the full source code of our autocomplete.php

// NuSphere PhpED code completion support for Codeigniter 2.1

* Code Igniter Base class first
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Benchmark $benchmark
* @property CI_Calendar $calendar
* @property CI_Cart $cart
* @property CI_Config $config
* @property CI_Controller $controller
* @property CI_Email $email
* @property CI_Encrypt $encrypt
* @property CI_Exceptions $exceptions
* @property CI_Form_validation $form_validation
* @property CI_Ftp $ftp
* @property CI_Hooks $hooks
* @property CI_Image_lib $image_lib
* @property CI_Input $input
* @property CI_Javascript $javascript
* @property CI_Lang $lang
* @property CI_Loader $load
* @property CI_Log $log
* @property CI_Model $model
* @property CI_Migration $migration
* @property CI_Output $output
* @property CI_Pagination $pagination
* @property CI_Parser $parser
* @property CI_Profiler $profiler
* @property CI_Router $router
* @property CI_Session $session
* @property CI_Sha1 $sha1
* @property CI_Table $table
* @property CI_Trackback $trackback
* @property CI_Typography $typography
* @property CI_Unit_test $unit_test
* @property CI_Upload $upload
* @property CI_URI $uri
* @property CI_Utf8 $utf8
* @property CI_User_agent $user_agent
* @property CI_Validation $validation
* @property CI_Xmlrpc $xmlrpc
* @property CI_Xmlrpcs $xmlrpcs
* @property CI_Zip $zip
* ==================== Put your 'models' here ======================
* @property cds $cds
* ==================== Then your own library =======================
* @property PHPExcel $excel
* @property PHPWord $word
* @property Cezpdf $pdf

class CI_Controller {};

class MY_Controller extends CI_Controller {};

* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Config $config
* @property CI_Loader $load
* @property CI_Session $session
class CI_Model {};

/* End of file autocomplete.php */
/* Location: ./application/config/autocomplete.php */

Now you are ready to use PhpED code completion for CodeIgniter MVC framework.

Code completion on your controller

phped code suggestion on controller

Try typing ‘$this->l’ then press Ctrl+Space 👿

Code completion for our own libraries (for example I loaded our excel library) when invoked in controller

phped code completion for excel library

example: type ‘$this->excel->’ then press Ctrl+Space 👿

Code completion for your own model when invoked inside controller

phped code completion for model inside controller

in autocomplete.php codes above, I include ‘cds’ as virtual property so I can call it’s code completion here on controller

Active record code completion in your model

phped code completion for CodeIgniter active record

It can show active record function suggestions

PhpED can also show active record’s function description. So you know what’s the parameter (and return value) to be expected from a function

phped codeigniter active record function definition

PhpED showing function definition for an active record function


A special case for query result

Since CodeIgniter database class’ query function returned a mixed type, PhpED can’t code-complete a variable that returned from your active record function (db->get, db->query, db->get_where, db->simple_query). For example, when you have code like this


then you try to type $query-> then press Ctrl+Space you will get a PhpED error message stating that PhpED can’t detect the $query variable type.

To overcome this, you have to use PHPDoc @var CI_DB_Result directive before $query variable, so your code would be like this

* @var CI_DB_result

Now, try typing $query-> then press Ctrl+Space, you’ll get code completion/suggestion for your database query result

phped query result code suggestion

PhpED showing code suggestions for a query result

Leave a comment ?


  1. Awesome stuff! I’ve been battling with this in vain for months – finally a solution that will make my life so much easier!

  2. Mattias Sandström

    Excellent article!
    I found one problem with code completion and using MY_Controller (in PhpEd build 7047 at least) and my own functions where not code completed. I solved this by adding the following line to autocomplete.php:
    require ‘core/MY_Controller.php’;
    and commenting out the following line in autocomplete.php:
    class MY_Controller extends CI_Controller {};

    Then all worked as a charm!

  3. Hey your contact form is not working. I am trying to find out if you would tweak your adsense checker script to be like Google adsense sandbox and if so, for how much? Sorry for double post.

  4. CodeIgniter is my PHP Framework of choice because of it’s comfort, extensibility and qualifications. Creating website using CodeIgniter Framework on PhpED is quite a pressure because of non-working value accomplishment for CodeIgniter’s MVC.

  5. Hi,thanks for the info,i want to ask about adding model,i have 5 model and i have define all of it,but only shown 3 models only.Are there any workaround how to accomplish it?Thanks a lot.

    • could you please send me your autocomplete.php (maybe upload it to free file hosting). I’ll look at it.

    • I already look at it. Nothing’s wrong with your autocomplete.php.

      If you wish, I can look into your models codes. You can send me your model files, upload it to free file hosting and send me the download link via contact form (so it will be private).

  6. Hi,it already works as it should be.Thanks a lot by the way. 🙂

  7. hi. i understand you have been using phpED with codeigniter successfully. really wish you could help me…

    i have developed few programs using CI framework without any special editor.. now i just discover this great editor call phpED.. installed it today .. but cannot figure out how to open my CI programs in phpED.. google around still don’t have a clue …

    your help is very much desired ..

    notes : i also use koolphp with CI for UI


  8. Awesome! Cannot believe this problem is solved with just a few clicks. Thank you indeed 🙂

  9. codelobster

    I suggest to try Codelobster.
    It has special plug-in for CodeIgniter autocompletion:

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>