PhpStorm
 
Get PhpStorm

Configure PHP namespaces in a project

Last modified: 17 June 2024

PhpStorm supports the PSR-0/PSR-4 autoloading standard, which stipulates that namespace names in PHP should be mapped to the directory structure. The directory marked with the Source root type in PhpStorm is considered to be the root for namespaces, and every directory created under it is considered to be a separate namespace.

When the Source root type is set, PhpStorm autocompletes the namespace name when you create a new class/interface/etc. inside this directory. For namespace names that don't match the PSR-0/PSR-4 project structure, the IDE displays an inspection warning in the editor.