Home / Snippets / How To Solve Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error
How To Solve Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error cover

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

14.1K

2 years ago

0 comments

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.
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this