13

I just installed PhpStorm 2020.2, and notice that all php base classes like Closure or mysqli are not been identified by the IDE.

Looking at the left where the PHP base files are, it just show the folders, like you can see in the first image, on the other hand, my older PhpStorm 2017 has the folders with the files inside it and cant identify all php base classes

PhpStorm 2020.2 enter image description here

PhpStorm 2017 enter image description here

7
  • Check so that all the plugins are up to date and that the php installation is as well.
    – Jite
    Sep 25, 2020 at 20:00
  • @Jite yes, the only one that wanst updated when I installed this version was a laravel plugin that I updated. But this version has the same plugins and configuration as the other phpStorm. PHP is installed and working, even phpunit tests are fine, just the IDE can't find these classes
    – SpaceDogCS
    Sep 25, 2020 at 20:09
  • When you put the cursor over the "error", what does it say?
    – Jite
    Sep 25, 2020 at 20:10
  • undefined class Closure, and ask me if I want to import, it is imported as you can see use Closure but the IDE tryies to find a Closure class in the same folder and show me import options of Closure classes from vendor folder
    – SpaceDogCS
    Sep 25, 2020 at 20:13
  • Could you try file > Invalidate Cache or Restart and invalidate the cache? Doing so forces the IDE to go dumb and learn all again, sometimes it helps!
    – Jite
    Sep 25, 2020 at 20:16

2 Answers 2

27

It's a known issue. AFAIK there is still no solid idea on why it happens and why only some users are affected.

https://youtrack.jetbrains.com/issue/WI-54626 -- watch this ticket (star/vote/comment) to get notified on any progress. Fixed in PhpStorm 2021.1.1 version.


Current workaround:

  1. Close IDE
  2. Locate folder where PhpStorm 2020.2 stores indexes/caches on your computer (see below)
  3. Delete that folder (as standard "Invalidate caches" does not help here)
  4. Launch IDE

Typical locations for caches folder for different OS:

  • Windows: %USERPROFILE%\AppData\Local\JetBrains\PhpStorm2020.2\caches
  • Linux: ~/.cache/JetBrains/PhpStorm2020.2/caches
  • macOS: ~/Library/Caches/JetBrains/PhpStorm2020.2/caches

For 2021.1 version: use File | Invalidate Caches... -- it now better clears them so no need to delete such folders manually.

  1. File | Invalidate Caches...
  2. Select top 2 options (maybe only 1st will be enough, but better use both)
  3. Use Invalidate and Restart button there
  4. After the IDE will restart, open the project and let re-indexing to complete.

enter image description here

If the issue persists (i.e. comes back the next day / after restart) then it's a different cause and you will have to wait for 2021.1.1 build.

4
  • 1
    Oh god that worked, I just didn't know how to research so lol, thank you so much, I lost my afternoon, but at least know everything is working fine, I'll update the title to match the real issue
    – SpaceDogCS
    Sep 25, 2020 at 20:45
  • Confirmed - cleaning from PHPStorm menu by "File -> Invalidate Caches / Restart" didn't work at all. Manual cleaning from .cache folder did the job perfectly. In my case it was after PHPStorm update to version 2020.3.2.
    – wit0ld
    Feb 21, 2021 at 18:44
  • I just had the same problem in 2022.3.2 and the workaround still worked.
    – Wipster
    Feb 16 at 15:57
  • Yes, obviously it's persisting in 2023.1.2... But the workaround is still valid. Thanks for the advice.
    – El Ackabar
    May 17 at 20:07
3

Before doing all that @lazyone has said 👌, make sure that the Phpstorm php interpreter is set correctly. You can check that from here:

File/settings/languages & frameworks/php/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.