Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indent after opening php tag

Tags:

php

phpstorm

I just started using PhpStorm, and it doesn't want me to indent the first line after the opening <?php tag. I prefer to, so I do it manually each time. This may seem rather trivial, but after searching I cannot find any definitive reasons to do it one way or the other. Is there a best practice for indenting after opening a script tag?

like image 639
Jesse Schoff Avatar asked Feb 20 '13 20:02

Jesse Schoff


2 Answers

While not directly defined, PSR-0, PSR-1, PSR-2, and PSR-3 do not indent after the PHP tags. Since the PSR's are the defacto standard of PHP coding styles I would recommend sticking to the PSR Standards and trying to break your habit of the initial indent, if for no other reason to reduce the length of lines and thus line wraps and line breaks.

like image 145
WhoaItsAFactorial Avatar answered Nov 15 '22 08:11

WhoaItsAFactorial


Open PhpStorm's settings. Under Project Settings -> Code Style -> PHP you should find a tab Other where you can set the desired behavior by clicking the checkbox Indent code in PHP tags.

But as the other answer suggests, this is probably not a good idea, as it is against any common coding standard I know of. :-)

like image 27
Alexander M. Turek Avatar answered Nov 15 '22 08:11

Alexander M. Turek