近日项目需要使用lumen开发项目,开发工具采用phpStorm,没有代码提醒肿么办?
于是想到了万能的github ,终于找到了一款代码提示插件
https://github.com/barryvdh/laravel-ide-helper
如何使用呢?
D:\phpStudy\WWW\lumen\blog>composer require --dev barryvdh/laravel-ide-helper Using version ^2.4 for barryvdh/laravel-ide-helper ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 1 update, 0 removals - Installing symfony/class-loader (v3.3.6): Downloading (100%) - Updating barryvdh/laravel-ide-helper (dev-master 1deadce => v2.4.3): Checking out 5c304db44f symfony/class-loader suggests installing symfony/polyfill-apcu (For using ApcClassLoader on HHVM) Writing lock file Generating autoload files
这里做个区分:
如果是lumen 则:
打开 bootstrap/app.php 加入代码
if ($app->environment() !== 'production') { $app->register(Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); }
如果是laravel的话,
需要打开 configs/app.php
在 provideers 的数组中 添加
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class
然后使用:
D:\phpStudy\WWW\lumen\blog>php artisan ide-helper:generate Exception: Class cookie does not exist Skipping \Illuminate\Support\Facades\Cookie. Exception: No application encryption key has been specified. Skipping \Illuminate\Support\Facades\Crypt. Exception: Class mailer does not exist Skipping \Illuminate\Support\Facades\Mail. Exception: Class session does not exist Skipping \Illuminate\Support\Facades\Session. Exception: Class filesystem does not exist Skipping \Illuminate\Support\Facades\Storage. Exception: Class cookie does not exist Skipping \Illuminate\Support\Facades\Cookie. Exception: No application encryption key has been specified. Skipping \Illuminate\Support\Facades\Crypt. Exception: Class mailer does not exist Skipping \Illuminate\Support\Facades\Mail. Exception: Class session does not exist Skipping \Illuminate\Support\Facades\Session. Exception: Class filesystem does not exist Skipping \Illuminate\Support\Facades\Storage. A new helper file was written to _ide_helper.php Unexpected no document on Illuminate\Database\Eloquent\Model Wrote expected docblock to D:\phpStudy\WWW\lumen\blog\vendor\illuminate\database\Eloquent\Model.php
执行完成后:
我把_ide_helper.php 改成了 _ide_helper.txt 上传上来,可以查看
然后打开:根目录下的composer.json 添加以下代码:
"scripts": { "post-update-cmd": [ "php artisan clear-compiled", "php artisan ide-helper:generate", "php artisan optimize" ] }
以上配置好以后,打开控制器试试看:
代码提醒完成。