YII2項目中重寫PhpStorm中對方法function的註釋代碼

1說明

Yii2默認的可訪問的路由都是action開頭的,可是當項目多了action名稱變長了,每次都要轉換大小寫對action進行全局的搜索,非常不方便,因此重寫了phpstorm對function註釋的工具,這樣咱們寫好action方法的時候只要輸入/**而後再按一個回車就能夠出現如下代碼了,以下圖,自動對action進行了拆分,這樣就能愉快的搜索了
圖片描述php

2操做步驟

·依次打開File->Settings->Editor->File and Code Templates(或者使用快捷鍵ctrl+shift+s)
·找到界面右側的Includes,再點擊PHP Function Doc Comment,接着把如下代碼複製進去,點擊apply->ok便可html

三、配置代碼

/**
* @note: 
#if($NAME.length()>6)
    #set($formatAction = '')
    #if($NAME.substring(0,6) == 'action')
        #set($len = $NAME.length())
        #set($actionName = $NAME.substring(6,$len))
        #set($actionLen = ${len} - 6 - 1)
        #foreach($start in [0..$actionLen])
            #set($end = ${start} + 1)
            #set($tmpStr = $actionName.substring($start,$end))
            #if($tmpStr.toUpperCase() == $tmpStr)
                #set($tmpLowerStr = $tmpStr.toLowerCase())
                #if($start != 0)
                    #set($formatAction = "${formatAction}-")   
                #end
                #set($formatAction = "${formatAction}${tmpLowerStr}")
            #else
                #set($formatAction = "${formatAction}${tmpStr}")
            #end
        #end
    * @action $formatAction
    #else
        * @func $NAME  
    #end
#else
    * @func $NAME    
#end
${PARAM_DOC}
#if (${TYPE_HINT} != "void") * @return ${TYPE_HINT}
#end
${THROWS_DOC}
*/

四、相關網站

http://velocity.apache.org/en...
https://wizardforcel.gitbooks...git

相關文章
相關標籤/搜索