Proper line-ending for an open-source PHP project

Posted on

QUESTION :

What is the proper line-ending preferences for an open-source web project? Obviously it includes source code of PHP, HTML, CSS and Javascript.

The source code is managing via Github now, and there are Windows (8 & 7), Linux (Ubuntu) and OSX developers inside the team, which means all the major operating systems.

P.S. We are using “Windows” CRLF line-ending, plus “UTF-8 without BOM” right now, without facing any problem, however I think it might be better to use “*nix/OSX” LF style. I heard some stories about the problems that caused by the additional “CR” on Linux or OS X.

ANSWER :

windows line ending will cause problems on Linux and some times on Mac too. I’ve seen some Mac files on linux which appear to have a ^M at the end of each line.
So, you best choice is the Linux line ending…

On Windows, Programmer’s notepad can handle *nix line endings, even if Notepad.exe can’t. Also, Git can automatically convert line endings: see https://help.github.com/articles/dealing-with-line-endings

Leave a Reply

Your email address will not be published.