Certainly! This is a recent and common issue affecting many Laravel developers using VS Code with the Intelephense PHP extension.
What's Going On?
Intelephense relies on symbol indexing: it reads all PHP files and builds an "index" of classes, functions, etc. If it can't find files for Laravel (usually in vendor/), it assumes they don't exist and flags them as undefined.
Root Causes and Solutions:
1. The Vendor Folder Is Excluded From Indexing
Recent updates to Intelephense, VS Code, or your workspace settings may have changed the exclude/include patterns. If vendor/ is excluded, Intelephense can't see Laravel's framework classes.
Check Your VS Code Settings:
- Go to settings.json (User or Workspace).
- Look for
files.exclude,search.exclude, orintelephense.files.exclude.
Make sure vendor/ is NOT being excluded.
Example of a potential problem:
"files.exclude": {
"**/vendor": true, // <-- should be false or absent
}
How to fix:
// Remove or set to false:
"files.exclude": {
"**/vendor": false
},
"search.exclude": {
"**/vendor": false
},
"intelephense.files.exclude": [
"**/.git/**",
"**/node_modules/**",
// "**/vendor/**", // <-- REMOVE THIS
]
2. You Recently Ran composer install with --no-dev or the Vendor Folder Is Missing
Make sure you've run a normal composer install, and that vendor/autoload.php and your Laravel dependencies exist.
3. Force Intelephense to Reindex
Sometimes the symbol index gets corrupted. You can manually trigger a reindex:
- Open the Command Palette (Ctrl+Shift+P)
- Type "Intelephense: Index workspace" and run it
4. Composer autoload Issues
Make sure you have a correct composer.json and up-to-date autoload:
composer dump-autoload
5. Try Clearing Intelephense Cache
- Close VS Code
- Delete the cache directory:
- macOS/Linux:
~/.config/Code/User/workspaceStorage/ - Windows:
%APPDATA%\Code\User\workspaceStorage\
- macOS/Linux:
- Reopen VS Code
Or through Command Palette:
- Run "Intelephense: Clear Cache"
6. Still Not Working? Try Disabling Other Conflicting Extensions
Sometimes PHP Namespace Resolver or other PHP extensions interfere with Intelephense.
Try disabling all PHP-related extensions except Intelephense, reload, see if it resolves.
TL;DR Step-by-step:
- Ensure
vendor/is not excluded from Intelephense or VS Code settings. - Run
composer installandcomposer dump-autoload - Use "Intelephense: Index workspace" from the command palette.
- If still broken, clear the Intelephense cache.
- Disable other extensions if necessary.
- Restart VS Code.
Common settings snippet to add to your settings.json:
{
"intelephense.files.exclude": [
"**/.git/**",
"**/node_modules/**"
// Do NOT include vendor here!
],
"files.exclude": {
"**/node_modules": true,
"**/.git": true
// Do NOT exclude vendor!
}
}
References
If these solutions don't work, try uninstalling/reinstalling Intelephense or testing in a new workspace to isolate issues.
Let me know if you need further help!