1.安裝
composer require --dev --prefer-dist bazilio/yii2-stubs-generator
php
2.配置console.php
2.1 以yii2-basic template爲例,打開config/console.php,添加以下代碼:
'controllerMap' => [
'stubs' => [
'class' => 'bazilio\stubsgenerator\StubsController',
],
],
2.2 運行命令,注意文件路徑,
php yii stubs config/console.php
具體內容可運行下列命令查看:
php yii stubs -h
3.打開phpstorm插件File Watchers,若是沒有請先安裝,下面以windows爲例具體說明。
3.1 導入yii2-stubs-generator:File->Settings->Tools->File Watchers;
3.2 點擊右側中間的綠色圖標,選擇./vendor/bazilio/yii2-stubs-generator/watcher.xml文件進行導入;
3.3 編輯:選取yii2-stubs-generator,點擊右側的小鉛筆進行編輯,具體配置以下:
3.4 配置scope,點擊'...',選擇‘shared’
3.5 配置Program和Arguments,黃色的警告忽略便可
3.6 點擊"OK",完成編輯;回到外層,繼續點擊"OK",完成配置。
這樣yii2-redis就有代碼提示了(^∀^)
git
說明:找到./vendor/yiisoft/yii2/Yii.php,右鍵->Mark as Plain Text,這樣能夠避免phpstorm提示Yii多重定義。github
參考文獻
【1】https://github.com/bazilio91/...
【2】https://github.com/samdark/yi...redis