Different code format for *.phtml

Hello,

I need different code format options for *.PHP and for *.PHTML. I can't find it in the settings - *.PHP needs 4 spaces indent, but *.PHTML only 2, I need to set the style separately, but also need it to accept both PHP and HTML as normal PHP file. Is there any way to do so -

how do I set the style separately for these two file types?

0
2 comments

Hi there,

>but also need it to accept both PHP and HTML as normal PHP file. Is there any way to do so -

To have PHP highlighting/code completion, you need to tell IDE to treat it as PHP file.

For that you need to assign *.html pattern to PHP file (move it from HTML file) -- "Settings/Preferences | Editor | File Types"

It's an IDE-wide setting so will affect ALL projects. Maybe you can use more specific pattern (e.g. *.php.html)?

 

>*.PHP needs 4 spaces indent, but *.PHTML only 2,

You can achieve this by using .editorconfig file and EditorConfig plugin enabled for this project (it is now bundled by default in latest version).

1
Avatar
Permanently deleted user

Let's say it didn't work. Editorconfig is a great idea, but I added it to the root of project, containing one rule;

[*.{phtml}]
indent_size = 2

*.PHTML file is still having 4 spaces when reformatted. And yes, I updated to latest PHPstorm and restarted the editor.

 

What am I doing wrong?

____________________

EDIT: fixed when opening editorconfig in PHPstorm instead of Vim. There shouldnt be braces:

[*.phtml]

0

Please sign in to leave a comment.