Search code examples
phpnamespacesphpstormjetbrains-ide

How do I set up a namespaces sort order in PhpStorm?


I have a project with classes with folders structure:

  • entities
  • models
  • services
  • controllers
  • components
  • modules
  • и т.д.

For now PhpStorm allows to sort imports alphabetically (ascending order), but I don't satisfied of it. No matter why.

I want that if I click "ReformatCode" or "RefactorCode" or namespace Auto Import, PhpStorm do sort namespaces as I want. How do I do that? For example: do order like in the list above?


Solution

  • It's not possible. The only two options are sorting alphabetically and sorting by the import length.

    You might wanna submit this as a feature request, but to be honest with you, I don't think there's a great chance it's going to be implemented any time soon.

    https://youtrack.jetbrains.com/newIssue?project=WI