Configuring PHP Namespaces in a Project
IntelliJ IDEA comes with a configurable convention which specifies that the project root folder is also the root for the packages and namespaces. In other words: the project root folder is by default marked as Source and every directory created under it is considered a separate namespace. This complies with the PSR-0, also known as the Autoloading Standard, which prescribes that classes and namespaces in PHP should match the directory and file structure, and vice-versa.
According to PSR-4, any directory can be explicitly assigned a namespace prefix. With this project structure, autoloaders in different PHP frameworks become interoperable.
On this page:
Detecting Namespace Roots Automatically
When you open a project that contains at least one file with a namespace, IntelliJ IDEA displays a message with a proposition to set the namespace root.
Accordingly, when no namespace root has been configured yet and you create a class, IntelliJ IDEA proposes to configure the namespace root.
You can also trigger namespace root detection by choosing on the main menu. The Directories dialog box that opens, shows the folders under the project root folder with the project root folder marked as Source, which means that it is the root for all the namespaces in it. Accept the settings by clicking OK or configure the namespace root manually as described below. Learn more about marking folders in Configuring Folders Within a Content Root.