Hacker News new | comments | show | ask | jobs | submit login
PHP 5.5.8 Released (php.net)
72 points by babawere 1376 days ago | hide | past | web | 60 comments | favorite



A bugfix point release hardly worth mentioning.

"This release fixes about 20 bugs against PHP 5.5.7 components."


>Passing DOMDocumentFragment to DOMDocument::saveHTML() Produces invalid Markup

Of the few things PHP should be great at, parsing and generating html markup is close to the top of the list. Yet DOMDocument has given me so many headaches...


PHP has a reputation as a language that makes dead easy to write very ugly sphagetti code. As far as I learned a lot has chaned since last time I was using PHP - something like 5 years ago.

Is there any good book or other resource which describes modern PHP with best practices, parts to avoid, etc?


I've seen this around a few times, seems to be what you're looking for http://www.phptherightway.com


If I were you, and I wanted to see how elegant and great PHP can be, I would just go check out and learn Laravel 4.

I recently moved from CodeIgniter 2.x over to Laravel, and it was like breathing fresh new air at the top of a mountain. Everything is cutting edge, organized, and fun to code again. Sounds like hyperbole, but for real it reinvigorated my programming efforts.

Check it out here: http://laravel.com/


And if you're going the Laravel route (which I certainly recommend, I've used it a couple times here and there when PHP has been required), check out CodeBright by Dayle Rees (a Laravel core team member) on Leanpub (https://leanpub.com/codebright). It was the manual I needed to get going.


My\Full\Classname

Namespace convention sucks. That is all.


>> PHP has a reputation as a language that makes dead easy to write very ugly sphagetti code.

I believe that programmers ability to write poor code is quite language agnostic.


I'd agree that PHP really isn't that bad (at least, from the perspective of someone who started writing web apps using C, Perl, and Java). Some missing or clunky meta/higher level features feel limiting to me, but more or less it seems to be as successful as its other dynamic scripting siblings when it comes to tools devs have used to ship.

The big problem with PHP is that it grew to popularity as it grew into a turing-complete templating language, and the major paradigm for it was more or less the idea that documents are programs. That actually encouraged mixture of logic and presentation concerns.

There are some other warts possibly worth railing at, but that's really the main place it gets its probably deserved reputation for having more spaghetti code, even though pros working in have long since moved on from that paradigm.

FWIW, this is also its strength: it's a very short distance with a gentle curve from authoring documents to authoring dynamic documents. I don't think anything else matches it.

Of course, the curve from there to a larger application, that can be a different story, depending on what kind of guidance one has (and most likely, without guidance, ontology will recapitulate philology, as they say).


I totally agree with you, it's not a perfect language. However, given the nature of 9/10 web applications (CRUD with some relationships between models), it does it's job just fine.


From my personal experience, I disagree. I have seen a greater percentage of poor codes in languages that a lower entry barrier than those that require more initial investment. Most poor coders I've met are lazy coders (in the wrong side of it).


Yes, there are plenty of crap coders and agree with your argument but, again, it's not really the language's problem. Actually, I believe it's quite opposite. It's a side effect of success.

PHP was suitable for new programmers because of how easy it is to deploy, learn. PHP3, the first version of PHP which was widespread, was released during the dot com bubble. When everyone and their mums was into Web. Everyone started writing tutorials, passing their shitty skill set. to new developers. Which produced more crap developers.


Learn how to use the Symfony Framework:

http://symfony.com/

That is modern PHP done right.


Actually, Symfony seems like some kids went to basic OO design courses and took everything there seriously. It also causes the end product to be measurably the slowest in the world. http://www.techempower.com/benchmarks/

I think this is the worst symptom: Sure, you can write snappy code that performs fast but when you try to reach a higher abstraction level, all those fundamental design failures catch up and make everything awkward and just bad.


I'm not sure that PHP done like Java is "right."


I think the best answer, probably, is that modern PHP done right uses some kind of framework, or at least a PSR-0 autoloader, url routing, proper data security and some kind of templating to separate the logic from the view.

It can (and has been) argued that PHP is itself a templating language and that the added abstraction of something like Twig is unnecessary... while that's technically true, scaling that gets you trainwrecks like Wordpress' API, where it's all but impossible to write plugins without mixing html in with the code. You also get nice things like macros, auto-escaping, and caching with a template engine, and you would probably end up having to reimplement a lot of that at some point anyway.

Although what Laravel uses (blade) for templating looks pretty close to bare PHP, so there's plenty of room for minimal abstraction.

But all of it is light-years ahead of the nightmare that is typical legacy PHP.


I am reading "Apress Expert PHP and MySQL", the code is very releasable, it teach good practices about security and sql management, is more target to beginners and intermediate level programmers, but i really like how the author view and teaching skills.


The Laravel book by Taylor (creator of Laravel) is great for even non-Laravel users. https://leanpub.com/laravel


In my judgement, PHP best practice is #1 to never write anything new in it. And where it does already exist, #2 is to ideally write replacements (or do an incremental migration) in something else with a better overall balance of positive to negatives, that fits best, typically Python, Java, C or a sh.


Your judgement kind of sucks.


I'd recommend this for modern PHP: http://www.nodebeginner.org/

It's a great intro on how to write sphagetti code with out losing face.


This is not a PHP book, and is pretty old to begin with.


Are you sure it's a PHP book? It says it's a node.js book.


I think he is being sarcastic


smart ass


Aaaaaaand cue 250+ comments complaining about PHP, mostly centered around issues that were much bigger in 2009 than they are in 2014...


Aaaaaaand before that happens, cue multiple comments whining about how it's about to happen.


20 GOTO 10


Interesting believable factoids about PHP:

1. PHP supports goto since version 5.3.0; people speculated that term "troll driven development" in announcement was not a joke.

2. $ variable prefix in Perl was a joke about Hungarian notation and first BASIC dialects. PHP take that joke seriously.


If most critique centers around issues that have been solved, that doesn't imply that there aren't critique that hasn't been solved. I honestly can't think of a single good reason to PHP these days. Node.js is certainly better, so is Django. The only benefit of PHP is that you can create a small script quickly on a host that you don't control. Therefore PHP shouldn't be considered for anything serious.


How are Django and Nodejs better than other frameworks written in PHP like Laravel, Synfony and Yii?. Are your claims base on the fact that one day you hear someone say "yeah, this language/framework is better than PHP" or "this language have better syntax" and follow the trend, because in the web development context, i think that PHP is very capable and useful to accomplish anything related to the it IMO.


Python and JavaScript are proper and beautiful languages, PHP is a merely a wrapper.


Are you trolling?

I can understand the case for Python, but Javascript gets almost as much hate as PHP, and for many similar reasons.

And anyway, logically that suggests the core problem with PHP lies within C, if PHP is just a wrapper. Would you also say C is useless, or not worth taking seriously?


That is subjective and unrelated to my question, could please give me proper well based answer to the issue that wrote above, or i just have to assume that your claims are based in the examples that i gave in the same and you are just a troll?


php\namespace\tragedy


We got over it, moved on and built things.


How does this compare to the latest HHVM?


It looks like this is mostly bug fixes. So I imagine this will have little impact on HHVM


Also, I believe HHVM is looking for 5.4 parity, also I would imagine that some of these bug fixes would not need to be looked into since it's two entirely separate projects.


Since anything PHP-related on HN is bound to spur the usual PHP hate, here's something that might confuse the haters: PHP is actually faster than Go in many cases (according to http://www.techempower.com/benchmarks/#section=data-r8&hw=i7...).


I do not consider myself an hater (I have used both php and go). I would say the results on that page are consequence of php having more mature database drivers (written in C) than go, that is still in its infancy. If you look at for e.g. Plaintext it is more in line with what one would expect from a compiled language versus an interpreted one.


God, these comments are awful


I hope that's just mild disgust and not surprise... it's HN. History repeats itself every twelve minutes.

[edit]Which is not to say I don't agree with the "PHP is garbage" comments. I just also agree with the "seriously, we read all of this the last three thousand times PHP articles were posted, please shut up" snark.[/edit]


If PHP is garbage, every article about PHP should be about PHP being garbage to make sure everyone stays away from PHP.


[deleted]


So you declass PHP to a fancy templating engine because you have had problems with third party plugins for Wordpress?

On a related note, I just downloaded a Fart-app and my iPhone 2G froze. I'm glad Apple is developing, but they should just abandon the consumer market.


Your point?


Disappointed with the comments in here, I was really expecting at least one joke about Python 3 adoption.


Thanks for letting me know! Going to update on my development environment so I can run our tests against it to be sure nothing broke.


Friendly reminder that we can't have anything involving PHP without:

* complaints about features it has or has not

* a reference to that "a fractal of bad design" article

* how language x is better

* sarcastic, ironic or post-ironic notes about the above

* one guy pointing out we can't have anything involving PHP without the above


* before any of this happens, multiple comments whining about how it's about to happen.


He covered that in the last two bullet points


The post may have been edited. I've seen this happen with blog posts as well (someone points out an issue, blog post fixed, so the original comment makes no sense)


> a reference to that "a fractal of bad design" article

I've seriously started using it as a unit of measurement for the level of knee-jerk anti-PHP fanaticism present in a thread.


Posts about how needle/haystack hackstack/needle makes it "completely unusable"


No kidding, I mean I put square wheels on my car and it works just fine on my catenary road. Automotive engineers should get out of their circular wheel ivory tower now and then and see how good it works in practice.


Not so much for the road itself, but i see your point.


Ruby 2.1.0 is out.


Grayed out means down voted, right? But why?! First good comment on the thread: no bitching, no need to click the link to find ~20 fixes, here's the alternative, never look back. Period.


As someone who's professional life generally revolves around Ruby, and in the past has revolved around Python and PHP.. it's a stupid comment. PHP is a perfectly capable language of producing high quality products.. and that is what actually matters.


Might have something to do with it being off-topic and not adding anything to the conversation.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: