[split] CI3 Code Completion for library with PhpStorm - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7) +--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13) +--- Thread: [split] CI3 Code Completion for library with PhpStorm (/showthread.php?tid=66123) |
[split] CI3 Code Completion for library with PhpStorm - tduncklee - 09-07-2016 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.' ) ); } } RE: [split] CI3 Code Completion for library with PhpStorm - salain - 09-07-2016 Try this works fairly well https://github.com/nicolas-goudry/CI-PHPStorm-Code-Completion I use Third Method RE: [split] CI3 Code Completion for library with PhpStorm - tduncklee - 09-08-2016 (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... RE: [split] CI3 Code Completion for library with PhpStorm - salain - 09-15-2016 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. RE: [split] CI3 Code Completion for library with PhpStorm - jtf - 09-15-2016 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. RE: [split] CI3 Code Completion for library with PhpStorm - tduncklee - 09-15-2016 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. RE: [split] CI3 Code Completion for library with PhpStorm - salain - 09-15-2016 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. RE: [split] CI3 Code Completion for library with PhpStorm - tduncklee - 09-15-2016 That's it! It's actually: @property CI_Controller $ci (no _ ) It works! Thanks! |