Question: Code style for a PHP project with HTML/CSS/JavaScript


Code style for a PHP project with HTML/CSS/JavaScript

Answers 0
Added at 2016-12-13 11:12

I need to decide on a code style for a PHP project. The project consists mainly of PHP code, but it also includes its fair share of HTML, CSS and JavaScript.

By asking around, many have answered that I should be using PSR-2 because its the official style guide for PHP. Researching a little bit shows that it is not the official style guide, but it is unarguably the most popular one.

The issue I have with adopting PSR-2 is that it does not specify any style for HTML, CSS and JavaScript. I want the project to have a consistent style across all files. I don't want to end up with a style where I use 4 spaces for indentation in PHP, 2 spaces in JavaScript and tabs in CSS/HTML.

I have noticed that the larger PHP open source projects (such as MediaWiki and WordPress) have their own consistent style guides. But is it a good idea to adopt these for another project? I don't think I've ever encountered another project that adopted these code standards.

Source Show
◀ Wstecz