IntelliJ IDEA
 
Get IntelliJ IDEA
You are viewing the documentation for an earlier version of IntelliJ IDEA.

Configure PHP namespaces in a project

Last modified: 10 August 2022

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.