热搜:NVER node 开发 php

让phpstrom支持codeigniter框架实现 (GO TO )转到定义的功能

2024-07-25 10:00:02
让phpstrom支持codeigniter框架实现 (GO TO )转到定义的功能

2016-2-9PandaIT PHP

在上一遍中只是提到了可以使用增加一个ci_phpstrom.php文件的形式以支持codeigniter框架里面的一些方法和自定变量的的提示。如果我们在controller里面使用引入model层并不能实现 CTRL+左键 转到方法定义的功能。

这时候我们需要在CI_Controller头部或者是extends类里面增加以下注释说明也可以实现:

/** * @property m_userfound_lockedinfo $m_userfound_lockedinfo * @property m_withdrawal $m_withdrawal * @property m_withdrawal_faildata $m_withdrawal_faildata */class MY_Controller extends CI_Controller{     //...}

这时候我们在我们引入model的controller里面使用

class home extends my_api_controller{    function __construct()    {        parent::__construct();        $this->load->model('m_clientlog');    }        public function index_get()    {        $this->m_clientlog->updateClientLog();    }}

这时候我们就能发现m_clientlog里面的方法(function)会在phpStrom里面会有自动提示的功能,并且带有参数的说明,这对我们提高编程效率还是有很大帮助的。

同时我这边也写了一个输出注释声明的代码,每次增加 或者修改model文件的时候运行复制一下就能增加自动完成的提示了。

<?php/** * Created by PhpStorm. * User: UserPC * Date: 2016/2/5 * Time: 10:51 */$dirPath = 'D:\PHPWork\api\application\models';$files = scandir($dirPath);if($files){    foreach($files as $item)    {        if(substr($item,-3) == 'php')        {            formartEcho(str_replace('.php','',$item));        }    }}function formartEcho($str){    echo "@property {$str} \${$str}
";}

标签:CI CodeIgniter phpStrom