17

I found reformatting php source code in phpstorm for particular file is Ctrl+Shift+Alt+L. But is there any way to do for whole project files?

5
  • 2
    Have you tried invoking that action on folder (hint: in Project View panel) ?? Try it ... Commented Nov 13, 2015 at 17:01
  • Yes. I tired. Not happening. :( Commented Nov 13, 2015 at 17:20
  • Worked for me (test project though)... No ideas then. Commented Nov 13, 2015 at 17:51
  • I am using 9.0.2 version. Commented Nov 14, 2015 at 4:21
  • 1
    There was an option before to reformat folders on right click but there isn't one now in any of JetBrains products. I also have the same problem i need to reformat large codebase. Commented Nov 24, 2016 at 12:56

2 Answers 2

34

If you have issues opening the "reformat code" popup for multiple files, make sure that you don't have any open files as it'll otherwise only reformat the current open file (edit: sometimes - I still haven't been able to figure out why it allows you to reformat the entire code sometimes, but regardless, this fix will work if it doesn't allow you to).

You can simply right click any file on your file list and select "Close all".

Close all files in PHPStorm 2016.3

After you've done this, select the folder you want to reformat in the code view:

Project overview in PHPStorm 2016.3

Finally, with all files open you can now select "Reformat code" in the "Code" part of your main toolbar:

Reformat Code toolbar item in in PHPStorm 2016.3

You'll now get the regular popup that most guides seem to mention, but that's otherwise hidden for some reason:

Reformat Code popup in PHPStorm 2016.3

Sign up to request clarification or add additional context in comments.

1 Comment

This works for me in phpstorm 2018.2 - and though it works great subdirectories, the option is disabled if I select more than one directory at the same level. not a massive issue, but something to be aware of.
1

If you close all open code window and select a folder in the Project pane, you can use the keyboard shortcut or the Code->Refactor command and you'll get the dialog to reformat the code for the entire folder. This works in 2018.03, even for multiple subdirectories.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.