k0pernikus
k0pernikus

Reputation: 66510

How to fix namespace not being determined in new folders project?

I upgraded from phpstorm7 to phpstorm8. Now, whenever I create a new PHP class in an existing folder, the namespace is inserted correctly. Yet when I create an empty folder and create in there a new class, the namespace is empty and I would have to manually add it.

In pictures:

  1. Existing folder has the namespace:
    Example of the namesapce being inserted for an existing folder
  2. New folder in the same project lacks the namespace. Example of the namespace not being generated for a new folder

How can I tell phpstorm to always autogenerate the current namespace?

Upvotes: 6

Views: 10654

Answers (1)

Robin Kanters
Robin Kanters

Reputation: 5146

Sometimes PhpStorm doesn't correctly detect the appropriate namespace for your source directories.

You could try to fix this by going into Settings > Project: xxx > Directories, clicking the little 'P' next to your src/ directory and setting a root namespace for your project.

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

Upvotes: 10

Related Questions