Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>open changelog

>ctrl+f "PSR"

>0 results

Into the trash it goes.



Wow, PSR-2 (Coding Style Guide) seems fairly extreme (existentially, not in it's specifics which I haven't looked at) for PHP.

Part of me thinks it's odd, considering I never felt all that much freedom to change how I expressed things in PHP (at least not in the slightest compared to Perl).

Another part of me thinks that enough amateur programmers use PHP that some style guide may benefit them greatly. Then again, if people don't come to a better style through experience (or at least an explanation of the benefits or what mistakes it helps prevent) then is it really as useful?


The purpose of the PSRs is to help support and foster collaboration between members of the Framework Interoperability Group (the people who draft and publish the PSRs: consists of medium-to-large PHP projects including Symfony, Amazon, Drupal, Joomla, etc.). Having a common coding standard makes it much easier to publish code as part of other PSRs as questions like "tabs or spaces?" don't have to get rehashed every time a new PSR is drafted.

That's to say PSR-2 is not intended to a be a "best practices" type of thing: it's actually just the result of a survey of member projects at the time with each part chosen because that's what the majority of them did, even if it was just a simple majority or there were member projects were with the majority on, say, tabs vs. spaces but not, say, indentation size. Some of the FIG member projects have adopted it, but several haven't and don't intend to. It's useful if you don't have any other coding standard available, but easily ignored with no loss of interoperability with the other PSRs if you do.


Thanks for the explanation, that makes more sense.


Why would coding guidelines for PHP projects be in the language's changelog?


PSR-0 is widely adopted by anything relevant in the PHP ecosystem. Sure, those style guides might not be pitch-perfect but it is time for PHP to step it up and get some uniformity in their codebase. _At least_ adopting PSR-0 would have been a great step towards that.

Uncertain why I am getting downvoted for this (top parent) it is my personal opinion and just because you think otherwise isn't a valid reason.


How does the PHP project adopt PSR-0? PSR-0 is a standard for programs written in PHP; what would they do to adopt it that is in anyway better than the current situation?


Part of PSR-0 is a standard for autoloading namespaced classes, so, if you write you're own autoloader, implementing PSR-0 is neccessary to support loading libraries using that standard.

The situation before PSR-0 was a mess of different, incompatible directory layouts for loadable libraries.


Why would you expect a C project to use a PHP style guide?


PSR-0 doesn't really apply to C code. Also, php-src has had coding standards that really haven't changed for years: https://github.com/php/php-src/blob/master/CODING_STANDARDS


> At least adopting PSR-0 would have been a great step towards that.

PSR-0 is broken on machines using filesystems that aren't completely case-sensitive.

Implementing PSR-0 also takes about five lines of code. Sure, it's more boilerplate, but it's not something that needs to be in core.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: