Features Releases

Renaming a PSR Namespace Directory in PhpStorm 2017.1

When you rename a directory that is also part of a PSR-0/4 namespace structure, PhpStorm 2017.1.4 will now rename your namespace to match.

PSR-0 and PSR-4 are a direct 1:1 mapping between namespace levels and folders. Consequently, when you rename a PSR-0/4 directory, you then need to go and change all the namespaces for classes in that folder, to match the new directory structure. Now PhpStorm 2017.1.4 will do the work for you.


This will work only if you’ve marked your directory as a sources root and have informed PhpStorm what the namespace prefix of the sources root is. Find out more about marking directories in this video.

This will work for all files in the renamed directory, plus any sub-folder with files in them, so you can be sure that all your namespaces will be correct when you’ve updated a namespace by renaming the directory.

– Gary & The PhpStorm Team

image description