Posts Learn Components Snippets Categories Tags Tools new About
/

How To Solve Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error

Learn how to solve visual studio code PHP intelephense keep showing not necessary error the easy way

Created on Oct 21, 2021

70 views

To solve visual studio code PHP intelephense keep showing not necessary error there are several ways.

Option 1: Update intelephense Settings


The 1st option is to remove the "**/vendor/**" from the "exclude" settings available to the "intelephense" config.
"intelephense.files.exclude": [
    "**/vendor/**", <== remove this line!
    "**/.git/**",
    "**/.svn/**",
    "**/.hg/**",
    "**/CVS/**",
    "**/.DS_Store/**",
    "**/node_modules/**",
    "**/bower_components/**",
    "**/resources/views/**"
]

Option 2: Install laravel-ide-helper


The 2nd option Install laravel-ide-helper which will generate all of the helper classes for intelephense.
composer require --dev barryvdh/laravel-ide-helper
Then run php artisan ide-helper:generate to generate a file to help the IDE understand facades. Do note that you might need to restart Visual Studio Code.

Option 3: Update intelephense undefinedTypes


The other possible options is to set the "undefinedTypes" of the "intelephense.diagnostics" to false. This solution is the simplest so far so it's highly recommended.
"intelephense.diagnostics.undefinedTypes": false
One of the other solutions is to update the extension if it's available so if you have this option, do update it and it might have just works.

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)