laravel 5 ide自动补全 [英] laravel 5 ide autocompletion

查看:148
本文介绍了laravel 5 ide自动补全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想切换到laravel 5,但是在ide上遇到了一些麻烦-自动补全.我正在使用phpstorm. 在google中,答案总是以建议使用 https://github.com/barryvdh/laravel-ide-helper .但是对于Laravel 5来说似乎已经坏了.

我正在执行的步骤是:

  1. 安装Laravel 5

    composer create-project laravel/laravel 
    

  2. 需要帮助助手

    composer require barryvdh/laravel-ide-helper
    

  3. 添加了"Barryvdh \ LaravelIdeHelper \ IdeHelperServiceProvider",

    ....
    'Illuminate\Translation\TranslationServiceProvider',
    'Illuminate\Validation\ValidationServiceProvider',
    'Illuminate\View\ViewServiceProvider',
    'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
    

  4. 尝试生成帮助文件

    artisan ide-helper:generate
    

但是它总是会因以下错误而中断:

exception 'InvalidArgumentException' with message 'There are no commands defined in the "ide-helper" namespace.' in C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console\Application.php:501

0 C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console\Application.php(535): Symfony\Component\Console\Application->findNamespace('ide-helper')
1 C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console

\Application.php(192): Symfony\Component\Console\Application->find('ide-helper:gene...')
2 C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console\Application.php(126): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Outpu
t\ConsoleOutput))
3 C:\xampp\htdocs\test\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(91): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Out
put\ConsoleOutput))
4 C:\xampp\htdocs\test\artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
5 {main}

也许有人遇到了同样的问题,可以为我提供帮助. 除了barryvdh的ide-helper之外,我对自动补全的其他解决方案也很开放.

解决方案

我遇到了同样的问题,并且此问题得以解决:

在运行php artisan ide-helper:generate命令之前,请确保已将php artisan clear-compiledphp artisan optimize标记为并清除PhpStorm通过选择以下内容进行缓存:

文件|使缓存无效/重新启动

自动重启后,PhpStorm将再次编制索引,并且一切正常.

对不起,我的英语不好.

已在完成这些步骤之后,像这样use Illuminate\Support\Facades\Auth一样导入您的Facade,将它们链接到_ide_helper.php文件中,例如use Auth.

I want to switch to laravel 5, but have some trouble with ide - autocompletion. I'm using phpstorm. In google, the answers always end up with suggesting to use https://github.com/barryvdh/laravel-ide-helper . But it seems like it is broken for Laravel 5.

The steps I am doing are:

  1. Install Laravel 5

    composer create-project laravel/laravel 
    

  2. Require ide-helper

    composer require barryvdh/laravel-ide-helper
    

  3. Added 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',

    ....
    'Illuminate\Translation\TranslationServiceProvider',
    'Illuminate\Validation\ValidationServiceProvider',
    'Illuminate\View\ViewServiceProvider',
    'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
    

  4. Trying to generate the helper file

    artisan ide-helper:generate
    

But it always breaks with following error:

exception 'InvalidArgumentException' with message 'There are no commands defined in the "ide-helper" namespace.' in C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console\Application.php:501

0 C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console\Application.php(535): Symfony\Component\Console\Application->findNamespace('ide-helper')
1 C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console

\Application.php(192): Symfony\Component\Console\Application->find('ide-helper:gene...')
2 C:\xampp\htdocs\test\vendor\symfony\console\Symfony\Component\Console\Application.php(126): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Outpu
t\ConsoleOutput))
3 C:\xampp\htdocs\test\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(91): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Out
put\ConsoleOutput))
4 C:\xampp\htdocs\test\artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
5 {main}

Maybe someone had the same issue and can help me. I'm open for different solutions for autocompletion other than barryvdh's ide-helper.

解决方案

I had the same problem and this fixed it:

Before you run php artisan ide-helper:generate command, make sure to php artisan clear-compiled and php artisan optimize as it's noted here. If this didn't fixed your problem, take a look at this and clean out PhpStorm cache by choosing this:

File | Invalidate Caches/Restart

After auto restarting, PhpStorm will index again and everything should work fine.

Sorry for my bad english.

Edited: After these steps import your Facades like this use Illuminate\Support\Facades\Auth link them inside your _ide_helper.php file like use Auth.

这篇关于laravel 5 ide自动补全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆