1、确认composer版本是1.x版本(不能用2版本以上)
composer -V
Composer version 1.10.22 2021-04-27 13:10:45
2、使用composer安装 laravel-ide-helper
composer require --dev barryvdh/laravel-ide-helper 2.6.*
如果是laravel 5.8 安装 laravel-ide-helper 2.6版本
3、修改composer.json,在"dont-discover" 增加 "barryvdh/laravel-ide-helper"
"extra": { "laravel": { "dont-discover": [ "barryvdh/laravel-ide-helper" ] } }
4、在AppServiceProvider 类中register方法里注册服务
public function register() { if ($this->app->isLocal()) { $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); } }
5、生产缓存
php artisan ide-helper:generate - PHPDoc generation for Laravel Facades php artisan ide-helper:models - PHPDocs for models php artisan ide-helper:meta - PhpStorm Meta file
完成。