alfrednutile's avatar

Just curious why tabs not spaces for Laravel style guide?

[PSR-2] Code must use 4 spaces for indenting, not tabs, but Laravels docs note using tabs. Just curious as to why?

Maybe as the L5 docs are updated that the PSR-2 will be used here? http://laravel.com/docs/4.2/contributions#coding-style

Thanks,

0 likes
3 replies
isimmons's avatar

I have my editor (ST) setup for psr-2 but am using the editorconfig plugin to override for Laravel. It's irritating that Laravel doesn't just follow psr-2 since they are listed as a member project but whatever.

Here is my .editorconfig file which I just had to do some work on to get working correctly. Probably need more changes but in case it's helpful.

I'm not sure about indent size but guessing it's only 1 when using tabs. 4 tabs is ridiculously long :-)

# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true

#everything php following Laravel style guide
[*.php]
indent_style = tab
indent_size = 1
insert_final_newline = true

#override for blade since its mostly html
[*.blade.php]
indent_style = space
indent_size = 2

#I think most people use 2 spaces for these?
[*.{css,js,html}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false

2 likes
Aaronharun's avatar

"Indent_size" when used with tabs controls how many spaces a tab looks like in most editors not how many actual tabs are there.

From editorconfig:

indent_size: a whole number defining the number of columns used for each indentation level and the width of soft tabs (when supported). When set to tab, the value of tab_width (if specified) will be used.

Please or to participate in this conversation.