ide-helper
github地址:https://github.com/barryvdh/laravel-ide-helper
安裝 IDE HELPER:
<pre class="EnlighterJSRAW" data-enlighter-language="null">composer require barryvdh/laravel-ide-helper --dev</pre>
在config/app.php中的providers => 添加如下類
<pre>BarryvdhLaravelIdeHelperIdeHelperServiceProvider::class,</pre>
執行如下命令:
<pre class="EnlighterJSRAW" data-enlighter-language="php">php artisan ide-helper:generate</pre>
設置容器的名稱映射:
<pre class="EnlighterJSRAW" data-enlighter-language="php">php artisan ide-helper:meta</pre>
設置models的智能提示:
<pre class="EnlighterJSRAW" data-enlighter-language="php">php artisan ide-helper:models</pre>
此時若提示要缺少doctrine/dbal
將其安裝在dev下
<pre class="EnlighterJSRAW" data-enlighter-language="php">composer require doctrine/dbal --dev</pre>
<strong>方法二:</strong>
建立command一鍵設置代碼智能提示
<pre class="EnlighterJSRAW" data-enlighter-language="php">php artisan make:command RunLocal</pre>
修改command(路徑:App/Console/Commands/RunLocal.php)代碼如下
<pre class="EnlighterJSRAW" data-enlighter-language="php"><?php
namespace AppConsoleCommands;
use IlluminateConsoleCommand;
use IlluminateSupportFacadesApp;
class RunLocal extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = run:local;
/**
* The console command description.
*
* @var string
*/
protected $description = run only local;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if(App::environment() === local){
Config::set(database.connections.mysql.port,33060);
$this->call(ide-helper:generate);
$this->call(ide-helper:meta);
$this->call(ide-helper:models);
}
//
}
}</pre>
然後在Consle核心文件Kernel.php註冊:
<pre class="EnlighterJSRAW" data-enlighter-language="php">class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
RunLocal::class
];</pre>
然後執行命令即可
<pre class="EnlighterJSRAW" data-enlighter-language="php">php artisan make:command RunLocal</pre>
然後就可以進入擼代碼的正確方式了,(耿直的微笑
推薦閱讀:
TAG:集成開發環境 | IDEInnovationDesignEngineering | IDE集成開發環境 |