CodeIgniter and IntelliSense in Eclipse PDT
For those that are not aware, IntelliSense is a feature of the Eclipse IDE, which allows us to quickly inspect the properties of an instantiated object of some type, function parameters, auto-completion, short description, if available and so on. This is incredibly handy when developing applications, no matter the programming language. When developing with CodeIgniter, due to the style the framework is written, the IntelliSense is not working.
I found a post that describes how you could enable it but I couldn’t do it – perhaps it is just me personally that is unable to achieve the goal – see here.
After some thinking what to do – I realized that in most of the projects I am extending the Controller class and I am using my own. So in the extended class I just added the variables to the definition + phpdoc style comment. This way I succeeded in enabling the IntelliSense with Eclipse PDT and CodeIgniter’s main libraries. Here is the code:
<?php class MY_Controller extends Controller { /** * @var CI_User_agent */ var $agent; /** * @var CI_Benchmark */ var $benchmark; /** * @var CI_Calendar */ var $calendar; /** * @var CI_Cart */ var $cart; /** * @var CI_Config */ var $config; /** * @var CI_DB_driver */ var $db; /** * @var CI_Email */ var $email; /** * @var CI_Encrypt */ var $encrypt; /** * @var CI_Form_validation */ var $form_validation; /** * @var CI_FTP */ var $ftp; /** * @var CI_Image_lib */ var $image_lib; /** * @var CI_Input */ var $input; /** * @var CI_Language */ var $lang; /** * @var CI_Output */ var $output; /** * @var CI_Pagination */ var $pagination; /** * @var CI_Parser */ var $parser; /** * @var CI_Session */ var $session; /** * @var CI_Table */ var $table; /** * @var CI_Trackback */ var $trackback; /** * @var CI_Typography */ var $typography; /** * @var CI_Unit_test */ var $unit; /** * @var CI_Upload */ var $upload; /** * @var CI_URI */ var $uri; /** * @var CI_Xmlrpc */ var $xmlrpc; /** * @var CI_Xmlrpcs */ var $xmlrpcs; /** * @var CI_Zip */ var $zip; } ?>
Note that there is no need to initialize anything, update core classes in the system folder or anything else. Simple as extending the Controller and using it.
This post is also available in: Bulgarian
One limitation of going it in MY_Controller is that it only works in Controllers. To get it to work in Models, you would need to do thesame for MY_Model, and same for any custom libraries.
Yes, you are right here. But normally the use of these libraries is through the controller. So what you could do is when using get_instance, associate that to a variable that is defined with phpdoc comment
/**
* @var MY_Controller
*/
This way everything is fine.
and what about the CodeIgniter 2.0 because there isn’t Base4.php or Base5.php
Haven’t played with CI2.0 yet but with my approach I do not use any of the core libraries …. so no need for Base4/5 …
Other networks, namely Three and O2 have similar features but are not quite as polished and advanced as EE’s offering. Three and O2 offer apps that let you make calls and send texts, but EE’s integration is system wide on select iOS and Android devices.
Basically, if you outlaw good encryption, the only people that will suffer are the law-abiding. Everyone else, including bad actors, will be just fine.