Straight, simple and to the point. Nice.<p>Missing test and QA tools though. Probably an oversight, since the author does suggest following Derick Rethans and Sebastian Bergmann.<p>And another one: read up on the SPL library before you start re-inventing that wheel.
I like the general idea of this, but think that it is nearly useless in its current form. It's way too superficial. To teach newbies how to do things right it doesn't suffice to link to a few resources and hope that they'll read them (hint: they won't). Instead one needs more concrete code examples, etc. Which would obviously be too much for one page :)
PHP with these guidelines looks like JAVA to me, but without the relatively sane foundations.<p>It is fun how much a very old moralist sentence by Confucius applies well to PHP. He said 其本亂而末治者否矣 which can be translated, in software language development context, as "Build a nice, reliable language on shitty definition? Bullshit!".<p>(The word-by-word translation is "your - root - messy - and/but - leaves/result - governed/orderly - have ? not - hey!")<p>This sentence also resonates with the odd Turkish encoding PHPbug recently reported here: if you have so many wrong architecture decisions in the core of your product, no amount of patching and "under the rub" filling will save you.<p>Edit: added word-by-word translation + typo fixes.
<i></i><i>curl -s <a href="http://getcomposer.org/installer" rel="nofollow">http://getcomposer.org/installer</a> | php</i><i></i><p>is creepy. Never ever run other people's code without at least giving it a glance.
While PSR-1 has pretty good universal guidelines, PSR-2 goes too far in insisting on subjective preferences (spaces over tabs, 80-char lines, bracketing styles). We should not pretend that there is a "correct" answer to these choices, just as long as they stay consistent on a per-project basis.<p>All told, I love site, and I hope it keeps iterating. PHP may be ugly, but it's powerful, and most of its bad reputation comes from good coders having to pick up the pieces from bad coders.
I didn't understand this:<p><pre><code> 4.2. Properties
This guide intentionally avoids any recommendation regarding the use of
$StudlyCaps, $camelCase, or $under_score property names.
Whatever naming convention is used SHOULD be applied consistently within a
reasonable scope. That scope may be vendor-level, package-level, class-level,
or method-level.
4.3. Methods
Method names MUST be declared in camelCase().</code></pre>
Something to consider mentioning - there are some in PHP these days that take this sort of stuff a bit too far. Drives me nuts to see people writing classes to encapsulate a 3 column database result. So much overhead and boilerplate.
As a part-time PHP hater who often has to work with it professionally, I believe this is a fantastic resource. The bit on databases in particular is something that all PHP devs should read.<p>That said, it is difficult to bring a legacy code base in line with modern style, though you can improve it over time.<p>Also, this could benefit from some other gotchas, extremely surprising behavior and best practices for avoiding common pitfalls.
One point in and its already dead wrong, you never filter input, only output.<p>Edit: Everyone talking about databases: paramaterized queries, check them out.
I'm wondering why a specific code style is 'enforced' while it has nothing to do with interoperability.<p>Libraries with different code styles can be used together without problems. It seems like they are using the PSR to declare they're own style as superior.
I dont agree with the article all the way but it's certainly refreshing to see people trying to improve PHP coding practices instead of just complaining. Very well done.<p>That being said... Every language has its strengths and weaknesses. There is nothing fundamentally wrong with PHP (except maybe that if you look at it it's not a very exciting language, even a bit boring). Security for instance has nothing to do with the language itself. And as for PHP syntax, it's a blessing compared to some other languages; at least we don't have a semicolon debate in PHP land ;-)
The comments about namespace are somehow ironic: is it very common to find developers that know what classes are but not namespaces? The namespace concept is much simpler than class. Which makes me wonder: who is the target audience?
Hey, nice work. Wouldn't a wiki platform work better however, instead of git?<p>Edit: also might be worth adding a bit about steering clear of phpclasses.org as well as w3schools, they bother contain far more bad, than good code.
Are there any good books (or other resources) on modern PHP?<p>I last used PHP back with PHP3 (and then went C++ => Java => Python => Python/JavaScript => Ruby => Python/R), but a bunch of code I want to read at work uses PHP (with Zend). I no longer remember most of what I learned about PHP3, though obviously the PHP syntax seems to be at least somewhat readable as a sort of amalgam of Perl and C++ syntax and idioms. What does, e.g., Facebook use to get engineers who don't know PHP (but might know C++ or Python) up and running?
I suggest that you open up the doc source on github so that you can attract contributions from people while still maintaining editorial control.<p>A good example is: python-guide.org -- <a href="http://docs.python-guide.org/en/latest/index.html" rel="nofollow">http://docs.python-guide.org/en/latest/index.html</a>
Why the hell is required space indentation instead of tabs? Don't you know how to setup your editor? Don't you know that there are coders with special needs and they would like to setup another indentation, because they are using e.g. font size 20px to see your code?
this is great stuff - I'm a casual php hacker and this is just the sort of thing I need to help me out when I'm working in the language - saves me from having to be deeply embedded in the culture of a language I don't use "all day every day"....so thanks!
Right way to write PHP indeed. Sometimes I wish PHP itself was written this way.<p>Oh! The guide does not mention the case: if a class contains only one static method, please, use a function. It does not look as educated, but it's obviously a function.<p>Not PHP specific, I admit.
These guidelines won't save you from some bullshit PHP "rules", such as:
<a href="http://stackoverflow.com/questions/5810168/php-foreach-by-reference-causes-weird-glitch-when-going-through-array-of-objects" rel="nofollow">http://stackoverflow.com/questions/5810168/php-foreach-by-re...</a>