Code formatting settings

Verze:

16. 02. 2023

Zodpovědná osoba:

Dominik Šlechta

For setting the format we use the editorConfig file. It is placed in the folder where all projects are. Download the file here: .editorconfig. But after downloading it will only appear as a file without a file extension. But we need it as .editorconfig, instructions how to do it for example here: https://winaero.com/you-can-create-rename-files-start-with-dot-windows-10/

You still need to adjust the phpstorm. Unfortunately there is no way to set it up normally.

You need to open the settings with File | Settings or ctrl + alt + s and here go to Editor | Code Style.
Here we have more possibilities how to achieve the result:

  1. Let's use my preset scheme. We download for_work.xml. Next, in the settings (see above), next to the "Scheme:" selection, select the cogwheel and put "import Scheme" and select the file we just downloaded. A window will open, where we choose where (the field with the title schema, or the option to insert it into the current schema). Finally, make sure the "Enable EditorConfig support" checkbox is checked at the bottom. And we're done
  2. In the settings above, select "Scheme:" to "Default" in the "Stored in IDE" category (if not already set) and make sure the "Enable EditorConfig support" checkbox is checked. Here we also have to go to the sub-menu Editor | Code Style | PHP | Arrangement Here we set it according to the picture below.nastaveni obrazku

 

Finally, you need to set the same thing (see above) for new projects File | New projects setup | Settings for new projects | Editor | Code Style, so that this setting is applied to all new projects.

Now we need to check every first opened NOT new project to set the schema either to for work or to DEFAULT in the IDE category. Otherwise the formatting according to editorconfig will not be set.