Search code examples
phplaravellaravel-5phpstorm

How to get PhpStorm to recognize Laravel facades?


When using Laravel Framework (5.6), PhpStorm does not recognize methods when accessed via facades like this:

$user = User::find($id);

So it's always complaining that: "Method 'find' not found in User"

error message

I've got the Laravel Plugin & the Barry IDE Helper. What else do I need to do?


Solution

  • From the root of your project in terminal:

    composer require --dev barryvdh/laravel-ide-helper
    
    php artisan clear-compiled
    php artisan ide-helper:generate
    

    Reference: https://github.com/barryvdh/laravel-ide-helper#automatic-phpdoc-generation-for-laravel-facades