Welcome Guest, Not a member yet? Register   Sign In
Autocompletion Trick
#1

[eluser]goFrendiAsgard[/eluser]
The most terrible thing when develop CodeIgniter based application is netbeans/eclipse missing auto-completion feature. For example, when you load a model, netbeans/eclipse cannot automatically show you what functions available in that model.

There is a "trick" for that:
Code:
$this->load->model('your_model');
$this->your_model = new Your_Model();


By adding that line, now you can have a working auto-completion to make your development time more painless

However it has some consideration:
1. You will need to add an extra line for that
2. The model will be instantiated twice

​This trick also works for "library".
#2

[eluser]predi[/eluser]
Put this file into your "application" folder, name it "ci_autocomplete.php"
In this example i add my models and libs for autocompletion.
see ">>> CUSTOM..."

Code:
<?php
/**
* @property CI_DB_utility $dbutil
* @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_Language $language
* @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
*
* >>> CUSTOM >> models
* @property Section_model $section_model
* @property Config_model $config_model
* @property News_model $news_model
*
* >>> CUSTOM >> libs
* @property Captcha $captcha
* @property JS_loader $js_loader
* @property CSS_loader $css_loader*
* @property Lingua $lingua
* @property Simpleimage $simpleimage  
* @property Utils $utils  
*/

class CI_Controller {};

class CI_DB_Driver {
/**
  * Execute the query
  *
  * Accepts an SQL string as input and returns a result object upon
  * successful execution of a "read" type query.  Returns boolean TRUE
  * upon successful execution of a "write" type query. Returns boolean
  * FALSE upon failure, and if the $db_debug variable is set to TRUE
  * will raise an error.
  *
  * @access public
  * @param string An SQL query string
  * @param array An array of binding data
  * @return CI_DB_mysql_result
  */
function query() {}
};

/**
* @property CI_DB_utility $dbutil
* @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 {};

/**
* @return CI_Controller
*/
function &get;_instance() {}  
?>
#3

[eluser]goFrendiAsgard[/eluser]
I see, and I'm sure that's gonna work too.
But you'll need to edit your ci_autocomplete.php everytime you make a new model, isn't it?

Another consideration, the auto-completion will work even if you don't load the corresponding model.

good share however Smile
#4

[eluser]predi[/eluser]
Yeap. Adding "ci_autocomplete.php" not very convenient, but works :-)




Theme © iAndrew 2016 - Forum software by © MyBB