Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 648
k0pernikus Avatar asked Sep 19 '14 15:09

k0pernikus


1 Answers

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)

like image 84
Robin Kanters Avatar answered Oct 13 '22 00:10

Robin Kanters