Hi all,
I use netbeans and CI for a while now. Autocompletion is really missing. i found some tips like
this one but i’m quite lazy… so i wrote a @property generator :D that is available within all the project and with i can access all my libs / models.
* Tested in CI 2.0
* copy paste the code in a protected controller
* Just put the downloaded file in your application folder
* if you want the loaded class like loader / db… add a parameter in your URL.
If someone find the phpdoc syntax to allow the completion in a library - where you call CI from the get_instance(). ($this->ci)
function generate_autocompletion($with_declared_classes = FALSE) {
$this->load->helper("file");
$this->load->helper("download");
$classes = array();
if ((bool) $with_declared_classes === TRUE) {
$declared = get_declared_classes();
foreach ($declared as $class) {
if (strpos($class, "CI_") === 0) {
$classes[str_replace("CI_", FALSE, $class)] = $class;
}
}
}
$libs = get_filenames(APPPATH . "libraries/", FALSE, TRUE);
foreach ($libs as $file) {
$file = str_replace(".php", FALSE, $file);
$classes[str_replace("MY_", FALSE, $file)] = $file;
}
$files = get_filenames(APPPATH . "models/", FALSE, TRUE);
foreach ($files as $file) {
$file = str_replace(".php", FALSE, $file);
$classes[str_replace("MY_", FALSE, $file)] = $file;
}
$class_property = " /**\n";
$class_property.= " *\n";
foreach ($classes as $key => $value) {
$class_property.= " * @property {$key} \${$value}\n";
}
$class_property.= " */\n";
$declaration = $class_property . "Class CI_Model{}\n";
$declaration .= $class_property . "Class CI_Controller{}\n";
foreach ($libs as $file) {
$lib = str_replace(".php", FALSE, str_replace("MY_", FALSE, $file));
$declaration .= $class_property . "Class {$lib}{}\n";
}
force_download("autocompletion.php", "<?php \n{$declaration}\n?>");
}ps : tried to post in the wiki but not allowed. Someone allowed can post it if he wants.