[split] CI3 Code Completion for library with PhpStorm |
Has anyone gotten code completion to work from within a library with phpStorm?
I have an autocomplete.php file in my config dir and all autocompletes work correctly except for inside a library file. For example: class Some_custom_lib { protected $CI; public function __construct() { $this->CI =& get_instance(); $this->CI->load->model('some_custom_model'); } public function createSubrofile($post_vars) { $create_file = $this->CI->some_custom_model->create_file($post_vars); // <-- This will not autocomplete. if($create_file){ return array( 'code' => 200, 'message' => $create_file ); } else { return array( 'code' => 400, 'message' => array( 'error' => 'Error creating file.' ) ); } }
Try this works fairly well
https://github.com/nicolas-goudry/CI-PHP...Completion I use Third Method A good decision is based on knowledge and not on numbers. - Plato
(09-07-2016, 10:14 PM)salain Wrote: Try this works fairly well I tried that also. It to works perfectly for autocomplete everywhere EXCEPT inside a library file. Still looking for a solution...
It works in library.
Have you added your libraries and models? Libraries have to be added in the CI_Controller and CI_Model sections. Models only in the CI_Controller section. A good decision is based on knowledge and not on numbers. - Plato
Suppose that you have a library class name Foo like:
PHP Code: class Foo In order to PHPStrom know that that object is handling the CI instance, should add this comment to your class: PHP Code: class Foo Quote:Libraries have to be added in the CI_Controller and CI_Model sections.
Hi salain,
Yes, I did add it to both sections. This enables autocomplete of the library functions from inside a controller but autocomplete from inside the library for models does not work. I finally gave up and moved all my library code into models just to get autocomplete.
Hi tduncklee,
I think you need this comment at the top of your libraries to fix the autocomplete of the model @property CI_Controller $_ci The variable has to be the same as the get_instance is assign to. A good decision is based on knowledge and not on numbers. - Plato
That's it! It's actually:
@property CI_Controller $ci (no _ ) It works! Thanks! |
Welcome Guest, Not a member yet? Register Sign In |