how to get zend studio autocomplete with codeigniter
Asked Answered
G

4

9

I'm looking for a good way to get autocomplete and click-for-reference (whatever that's called) for libraries in codeigniter working in Zend Studio for Eclipse.

for instance, if i do $this->load->library('dx_auth'); $this->dx_auth->get_user_id();

zend studio doesn't know what it is..

There is this sortof hacky way to do it (see below, source), but i feel like there should be a better way of doing it..

Anyone have any ideas?

// All of these are added so I get real auto complete
// I don't have to worry about it causing any problems with deployment
// as this file never gets called as I'm in PHP5 mode

// Core CI libraries
$config = new CI_Config();
$db = new CI_DB_active_record();
$email = new CI_Email();
$form_validation = new CI_Form_validation();
$input = new CI_Input();
$load = new CI_Loader();
$router = new CI_Router();
$session = new CI_Session();
$table = new CI_Table();
$unit = new CI_Unit_test();
$uri = new CI_URI();
Gormandize answered 3/7, 2009 at 16:36 Comment(0)
S
7

Add CI's library path as an include path to your project.

  1. In the PHP Explorer, open your project and right-click on Include Paths
  2. Select Configure from the context menu
  3. Then in the include path dialog, select the Library tab
  4. Click Add External Folder...
  5. Browse to a local copy of CI and choose it's library directory (wherever it keeps those class files)
  6. Click Done

Voila, there you go!

I should note that you can also define include paths at the time of project creation.

Satang answered 3/7, 2009 at 16:56 Comment(1)
This question and answer are both four and a half years old. By now both CI and Zend Studio will have changed significantly.Satang
R
4

As Peter's answer instructs, adding an include path is definitely the best way to go. However, this relies on the docblocks in the CI source code to be complete, accurate, and not ambiguous. For example, if a methods @return is declared as Some_Class|false, the autocompletion won't know what to do with it.

To add to Peter's answer, you can also force PDT/Eclipse/ZSfE to treat any variable as an instance of a particular class like so:

/* @var $varName Some_Class_Name */
Rosamondrosamund answered 3/7, 2009 at 17:48 Comment(1)
Great tip w/the type-forcing via comments. I actually didn't know that. +!Satang
R
2

If you have imported the project from say, like SVN, then you might not have the PHP support enabled for this project. You can enable it by right clicking your project -> configure -> add PHP support...

Tested in ZS 7.2.1

Redskin answered 26/8, 2010 at 11:42 Comment(1)
I've been searching for this revelation for three long, annoying hours. Thank you Jussi!Mardis
T
0

i'm using zend studio 9, that is what i did: Add CI's library path as an include path to your project.

$this->load->model('my_model');
$my_model = &$this->my_model;
$my_model instanceof my_model;//add this ,zend studio can autocomplete 
$my_model->myfunc($foo,$bar);
Truncate answered 20/9, 2013 at 8:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.