Disable automatic PSR-0 Detection
Answered
I'm coding projects in PHP using IntelliJ, and since the last update to the most recent IntelliJ Ultimate Version, it seemingly activated the automatic detection of PSR-0 namespace roots. This is crazy annoying, as I lose all of my PSR-4 namespace configurations everytime I add a composer package to a project. Can you please tell me how to fix this issue????????
Please sign in to leave a comment.
You may want to untick “Settings/Preferences | PHP | Composer > Synchronize IDE Settings with composer.json" option.
("File | Settings | Languages & Frameworks | PHP | Composer" for IntelliJ IDEA)
That is actually unticked, and it just happened again. Crazy annoying as the source configs are essential for the proper test file generation(s) in the correct folders when you select the “Create PHP Test..” option for a class.
It seems to happen from time to time when submodules get added or removed.
Unfortunately, you can't fix this yourself. Please vote for WI-74888.
The only workaround would be to actually configure your PSR-0/4 structure in the composer.json file, as opposed to configuring it in the IDE.
Ok yes the solution was to write a composer.json file according to the PSR-4 autoload standard, and then tick “Settings/Preferences | PHP | Composer > Synchronize IDE Settings with composer.json", all namespaces are now properly and automatically recognized.