PhpStorm无法识别类中的CodeIgniter v3.0数据库方法

时间:2015-08-23 22:31:21

标签: codeigniter phpstorm

虽然有很多关于如何让PhpStorm识别CodeIgniter 2.x核心功能的答案,但我无法弄清楚如何让它识别CodeIgniter 3.0 数据库函数。

我的config目录中有一个autocomplete.php文件,非常适合CodeIgniter 2.x(以及大多数v3.0)。由于v3删除了活动记录类,因此不再识别数据库功能。

 // help IDE(s) support Codeigniter 2.0
  * @property CI_DB_active_record $db  <-- no longer valid.
  ...
 */

如何使用新的CI v3 DB类获得PhpStorm自动完成功能?

更新:这是我的autocomplete.php文件:

<?php
// help IDE(s) support Codeigniter 2.0
/**
 * @property CI_DB_query_builder $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
 *
 *
 *
 * These are samples entries to make my own functions work. Remove these and add you custom ones.

 * @property Tank_auth $tank_auth
 * @property Users_model $users_model
 * @property Firms_model $firms_model
 * @property Event_types_model $event_types_model
 * @property Files_model $files_model
 * @property Milestones_model $milestones_model
 *
 *
 */
class CI_Controller {}; class MY_Controller extends CI_Controller {}; class Welcome extends MY_Controller {}; class Admin_Controller extends MY_Controller {}; class CI_Model {}; class MY_Model extends CI_Model {};/**
 * @property CI_DB_query_builder $db
 * @property CI_DB_forge $dbforge
 * @property CI_Config $config
 * @property CI_Loader $load
 * @property CI_Session $session
 */
// class CI_Model {};
/* End of file autocomplete.php */
/* Location: ./application/config/autocomplete.php */

在控制器中,$ this-&gt; db-&gt; where();被识别,命令点击将我带到该功能的源。但是,$ query-&gt; num_rows()在单击时会出现“无法找到要转到的声明”错误。

在模型中,没有CI DB功能被识别。

2 个答案:

答案 0 :(得分:2)

  1. https://gist.github.com/topdown/1697338
  2. 下载gist文件
  3. 将它放在CodeIgniter项目的根目录中(<div class="panel-footer navbar-bottom"> @include('partials.footer-sched') </div> </body> </html> 所在的位置)。
  4. 在PhpStorm的项目视图面板中,转到(展开)index.php
  5. 右键点击system/core/,然后选择Controller.php
  6. Mark as Plain Text
  7. 执行相同操作

    我正在使用PhpStorm 9可能会有所帮助。

答案 1 :(得分:0)

使用以下步骤非常简单: -

  1. 创建并将phpstorm.php文件放在CodeIgniter项目的根目录中。
  2. 在PhpStorm的项目视图面板中,转到(展开)system / core /.
  3. 右键单击Controller.php并选择Mark as Plain Text。
  4. 对Model.php执行相同的模型导航。
相关问题