Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error

前端 未结 15 845
广开言路
广开言路 2020-12-04 06:14

After the latest update of PHP Intelephense that I get today, the intelephense keep showing an error for an undefined symbol for my route (and other class too), there is no

15条回答
  •  难免孤独
    2020-12-04 07:02

    This solution may help you if you know your problem is limited to Facades and you are running Laravel 5.5 or above.

    Install laravel-ide-helper

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

    Add this conditional statement in your AppServiceProvider to register the helper class.

    public function register()
    {
        if ($this->app->environment() !== 'production') {
            $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
        }
        // ...
    }
    

    Then run php artisan ide-helper:generate to generate a file to help the IDE understand Facades. You will need to restart Visual Studio Code.

    References

    https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/16

    https://github.com/barryvdh/laravel-ide-helper

提交回复
热议问题