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:
    Example of the namesapce being inserted for an existing folder
  • A new folder in one project is missing a namespace. Example of the namespace not being generated for a new folder

How can I tell phpstorm to always auto-generate the current namespace?

+3


source to share


1 answer


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.



enter image description here (you may not have as many directories listed in the right pane, depending on the complexity of your project)

+7


source







All Articles