天天看點

如何寫php ide helper,更好的IDE代碼提示:laravel-ide-helper

安裝

composer require --dev barryvdh/laravel-ide-helper

設定服務提供者

config/app.php:

Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,

5.5及以上版本不需要設定

設定隻在開發環境中加載

app/Providers/AppServiceProvider.php:

public function register()

{

if ($this->app->environment() !== 'production') {

$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);

}

// ...

}

設定自動更新

conposer.json:

"scripts":{

"post-update-cmd": [

"Illuminate\\Foundation\\ComposerScripts::postUpdate",

"php artisan ide-helper:generate",

"php artisan ide-helper:meta"

]

},

釋出配置檔案

php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config

設定鍊式調用支援、為函數生成幫助檔案

config/ide-helper.php:

'include_fluent' => true,

'include_helpers' => true,