How to fix namespace not being defined in project with new folders?
I have upgraded from phpstorm7 to phpstorm8. Now, whenever I create a new PHP class in an existing folder, the namespace is inserted correctly. But when I create an empty folder and create a new class there, the namespace is empty and I have to manually add it.
In images:
- There is a namespace in the existing folder:
- A new folder in one project is missing a namespace.
How can I tell phpstorm to always auto-generate the current namespace?
source to share
Sometimes PhpStorm incorrectly detects the correct namespace for your source directories.
You can fix this by going to Settings > Project: xxx > Directories
, clicking the little "P" next to your directory src/
and setting the root namespace for your project.
(you may not have as many directories listed in the right pane, depending on the complexity of your project)
source to share