Translate

Codeigniter and PHPStorm code auto completion

PHPStorm
PHPStorm is one of the best IDEs you can find in the market today. It provides a waste range of features for rapid development and supports range of technologies and frameworks. Over the years Codeigniter support have been shaken in PHPStorm for some reason, perhaps an oversight. Specially when its come to code completion support. You can clearly see this after Codeigniter 1.7. There is zero code completion support for Codeigniter 2.x version in latest PHPStrom. After some research, we have come up with a minor hack to fix this problem.

We will be updating controller.php and model.php in Codeigniter system folder, which is not advisable in general practice. Since, we are only adding a document block, Lets go ahead and do it, without worrying about it too much.

If you have your Codeigniter app ready, navigate to your system folder and open up controller.php and model.php in the core directory. Copy the lines below and paste them in each file. Most likely before the start of the class declaration.
/**
 * @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_Lang $lang
 * @property CI_Loader $load
 * @property CI_Log $log
 * @property CI_Model $model
 * @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_User_agent $user_agent
 * @property CI_Validation $validation
 * @property CI_Xmlrpc $xmlrpc
 * @property CI_Xmlrpcs $xmlrpcs
 * @property CI_Zip $zip
 * @property CI_Javascript $javascript
 * @property CI_Jquery $jquery
 * @property CI_Utf8 $utf8
 * @property CI_Security $security
 */
Now create a new file in your application/core call MY_Controller and extend CI_Controller. Now try accessing any of the CodeIgniter libraries. You should get code autocomplete for them. Do the same for CI_Model(use MY_Model and extend CI_Model).

3 comments:

Nerdcore is a free tutorial website about latest technological development, designing and programming. Nerdcore have tuts for all skill levels in web, desktop and mobile application development. Tuts and courses we provided are carefully crafted by expert developers and designers from www.waan.it