Live data from Hacker News

PHP: The Right Way

phptherightway.com

11–20 of 233 posts

Re: PHP: The Right Way

#11
post #9

I'm wondering why a specific code style is 'enforced' while it has nothing to do with interoperability. 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 think it's less about being "superior" than standardizing on a common style. Makes it easier to get up and running with someone else's code. But if your team agrees on a common but different style, that's fine too. It accomplishes the same goal. I'm only suggesting the official standard for new PHP developers.

Re: PHP: The Right Way

#12
Hey, nice work. Wouldn't a wiki platform work better however, instead of git?

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.

Re: PHP: The Right Way

#13
post #6

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.

I think that is kinda mentioned in the popular framework bit of the document.

Re: PHP: The Right Way

#15
post #12

Hey, nice work. Wouldn't a wiki platform work better however, instead of git? 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.

Will be moving over to GitHub pages w/ Jekyll soon to automate build process.

Re: PHP: The Right Way

#16
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.

That said, it is difficult to bring a legacy code base in line with modern style, though you can improve it over time.

Also, this could benefit from some other gotchas, extremely surprising behavior and best practices for avoiding common pitfalls.

Re: PHP: The Right Way

#17
post #14

These guidelines won't save you from some bullshit PHP "rules", such as: http://stackoverflow.com/questions/5810168/php-foreach-by-re...

How is that a "bullshit PHP rule"? If you for loop in C, setting a pointer each iteration, you would expect the pointer to still be set the the last assignment in the loop once you're out of it.

Re: PHP: The Right Way

#19
post #12

Hey, nice work. Wouldn't a wiki platform work better however, instead of git? 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.

Git (along with Github) may be better because of the higher control that you have over the development/writing with a not-so-high management work (you don't even need to have a git client in order to change content since the content is hosted on Github). It is easier to manage different versions, apply patches and so on. Dokuwiki might work well for this purpose because its (almost) 0-config setup, though.

Re: PHP: The Right Way

#20

One point in and its already dead wrong, you never filter input, only output. Edit: Everyone talking about databases: paramaterized queries, check them out.

I'd definitely filter input that goes into a database. But if you think the wording can be made better, definitely send a pull request. Thanks!
Post reply on HN