151 points · by jbyers · 13y ago · 132 comments
5.3 was the big break, 5.4 gave us $this in closures, and 5.5 fixed the age old password hashing issues while dropping generators in my lap.
Exciting times :)
It's coyote ugly, but it works. At least most PHP devs don't have the attitude associated with other popular web frameworks. They focus on getting things done.
As a disclaimer, PHP is not my go to language, but I've done some ugly scaling experiments with it. I'm just tired of the PHP isn't cool, let's mock it with no actual valid arguments that is common.
PHP ended up annoying me so much that I switched back to Perl (using mod_perl for performance critical stuff). However my latest project is being written in Golang (I know it's all just personal preference, but everything that I hated about PHP, Go seems to get right)
I know many HN members will already be familiar with the following blog post, but it highlights up many of my frustrations: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...
I left PHP around the time that v5 was recently released and v4 was still common, as did a lot of people (moving over to Python and later Ruby+Rails). I think a lot of people put PHP now down using their experiences of PHP4 (awful "object" features, irritatingly inconsistent standard library, ...) and PHP4/5 transition problems (which IRC were not really massive, but many libraries didn't deal with the compatibility breaks quickly so there were for a while issues knowing which libs and example code outside the "standard" library were compatible with 4,.x, 5.x, or both) before migrating away.
I assume a lot of the above has change considerably in the intervening years, but I think a lot of people assume instead that it is just as bad as it was when they migrated elsewhere.
That and there is a lot of bad code written in PHP largely due to its perception of being a beginners language (any environment that is easy for a beginner to dive into tends to make writing bad code as easy as it makes writing good code).
> It's not the prettiest language,
That I take as understatement, though I'm still supporting some ancient "classic" ASP code (fingers crossed that legacy will finally be stomped out by the end of this year...) so I can conclusively state there is worse in use out there!
> but people have been building insanely successful businesses on top of it for years. Think Facebook.
Remember though that Facebook don't use stock PHP: http://en.wikipedia.org/wiki/HipHop_for_PHP
I think not many people know how mature the tools in the php ecosystem are today, many people that switched to rails or whatnot years ago still think of PHP as it was 10 years ago, and yes that was horrible.
jQuery might've over-done it a bit with their most recent refresh, but that's a better example of what could be done.
The search feature, for instance, is complete garbage. If I'm typing in a method name, give me that method, not this: http://ca2.php.net/results.php?q=mysql_query&l=en&p=all
Is it so hard to do something like auto-complete? Wikipedia and many other API references do this.
Small things like this matter.
What I find difficult on the old site, and this beta site, is getting to the meat. I just can't grok the navigation.
I find the new site harder to read. I can't get to it in Chrome (not working), and it feels very amateurish. The only welcome addition - is being able to vote up comments and autocompletion/suggestions on the search.
Yuck.
<?php echo '<p>Hello World</p>'; ?>
ought to be
<p><?php echo 'Hello World'; ?></p>
I swear this is the cause of so many "Too Localized" issues on StackOverflow, due to nesting quotes within quotes and getting lost in tags. Echoing html makes things too difficult for beginners.
But great to see an improvement on the whole.
Also in some inner pages like this one http://www.php.net/manual/en/index.php left block is empty and page looks like misaligned. It might be better to borrow some ideas from Sphinx generated documentation style.
Load the page, with the tutorial block showing. Look under the PHP logo. See the purple "active" indicator underneath (obviously you do, because you commented on it)? To restore the original state, click the PHP icon.
Can anyone give me any tips?
(please don't suggest other programming language, I have wasted countless hours trying to decide. I will eventually try to learn other languages but decided to start with php for now. My main interest is webapps, so it would seem that php is the most popular - and easy - choice.)
I personally try to follow a couple basic rules. .php files should be a single <?php ?> block with nothing outside it, and .phtml files shouldn't use anything but if, foreach, and already defined variables. You'll end up with code that's both cleaner and better structured.
Second, if at all possible avoid Wordpress until you've already got a firm grasp of the language. Wordpress itself has a few decisions that made sense in PHP 4 but are terrible practice now (like using global functions instead of classes) and a few others that, while not technically wrong, were questionable even then (the loop). On top of that, the quality of code in third party themes and plugins varies wildly. If you copy the techniques you see there, you'll learn some awesome tricks, but you'll also learn every bad practice in the book. Until you've got enough experience to recognize the difference, you'll do yourself more harm than good.
Unless things have changed since I last looked, PHP files are all templates. Last time I used PHP, with symphony, I actually thought PHP was a pretty reasonable templating system.
A lot of code written by beginners (myself included, once) will put business logic as close to where it will eventually be rendered as possible, so you end up with code that looks like this
<ul>
<?php
// Thirty lines of database calls and string manipulation
foreach ($results as $result): ?>
<li><?= $result ?></li>
<?php endforeach ?>
</ul>
which makes intuitive sense but quickly leads to an unreadable template. It turns out that, even though you're writing these together, you'll rarely actually want to change them together. So you eventually learn to have template files and nontemplate files.The .php vs .phtml distinction has no relevance to the compiler. They're only really useful to a human in making that template/code distinction explicit.
https://github.com/symfony/Process/blob/master/PhpProcess.ph...
Or in other words, php files are only templates if you use them that way.
- Get into the habit of using PHPUnit early. If you haven't come across it yet there are plenty of tutorials on http://net.tutsplus.com/ that cover it's basic use. It may seem pointless to begin with but you'll be thankful later on.
- I know you said you didn't want suggestions for another language and I won't give you any. However alongside PHP I think it would be really beneficial to do a primer on basic computer science. An understanding of concepts such as language paradigms, design patterns and simple algorithms would inform your learning and explain why some of the advanced resources you come across later do things the way that they do.
Without you being more specific, I wouldn't know what to say other than build simple things with it, then more complex things, and keep looking at source of mature projects for inspiration and kicks. Also, modify existing things until they break, then do it again. As long as you're not dealing with sensitive data of yourself or others, don't be afraid of to just poke and pull at things, or to try an idea just to see if it works. Maybe some would advise against that, and maybe they're right, I am not a good programmer by any means. But I have fun doing it, and that's how I learnt.
Learning grammar and vocabulary is obviously the first step, but I think the real fun begins when you learn to express yourself freely, when the path between idea and execution gets shorter, and is less often interrupted by hunting down unexpected bugs. Even though that is possible without knowing all that much of the language, just by getting good at using the bits you do know, it still takes time in any case, and you will have to overcome frustrations. But no matter what language, it's worth it :)
Comment religiously. You'll thank yourself in six months.
You'll save yourself a lot of time if you learn to use Composer (http://getcomposer.org) to manage dependencies, and a templating system (twig, mustache, smarty, what have you) and class autoloading. PSR-0 (https://github.com/php-fig/fig-standards/blob/master/accepte...) is annoying, but it is really convenient once you get past the overhead. If you're on Windows, it really helps to get PHP running from the command line.
The bulk of my php coding really sits, in foreach loops, if statements (and comparison operators), and the use of arrays. Get to know arrays, build them, loop through them, echo out values, mutate them, they're your friend.
Learn about namespacing, functions and classes. Avoid globals but use the superglobals!
And as with all web programming, understand the browser/server lifecycle of a request. Start with the basics of HTTP.
google for REPL, than get one for php, so you can see results instantly. https://github.com/d11wtq/boris
Side by side speed comparison:
http://farm3.staticflickr.com/2859/9133368868_54f4a8cabb_h.j...
http://farm4.staticflickr.com/3700/9131157097_923af39b1b_h.j...
Iphone rendering:
http://farm8.staticflickr.com/7402/9133398088_4cd5d18661_b.j...
http://farm8.staticflickr.com/7288/9131186519_b00acc38a0_b.j...
Screw anyone who rags on PHP. Since 5.3, it's been one of the nicer languages I've ever used, and I'm exceedingly productive in it.
The best part? I can work in Brisbane, and get paid well for it. Not too many Ruby jobs around, or anything other than .Net and a little bit of Java.
I don't know if it's because it's "new", but the readability on documentation pages got worse. It's like I'm better off using (e)links to handle php.net searches.
With the negativity out of the way: MUCH nicer looking site. I look forward to using it the next time I find myself having to write PHP :)
The documentation pages are broken too. I guess the flat and typographical design is meant to improve the reading experience and not just for the sake of flatness.
https://dl.dropboxusercontent.com/u/2777218/Sans%20titre.pngI kid, I kid. Honestly that just looks like a broken page to me. Shift-reload?
Oh it breaks the site so that you can't enable the beta at all anymore without resetting cookies.
edit: It's just that all mirrors aren't up to date
Step into the future! Click here to switch to the beta php.net site.
Page just refreshes. Tried deleting all my cookies, didn't help.
Edit: Tried in IE10, Firefox, Chrome. I've never visited php.net on this computer before. IMO site is fail since they can't even get their beta site access feature working.
...has not been tested on Safari (ipad2 here)
Old one was at least professional and to the point, this one is pure garbage and looks like a web site for a grape drink.
The most important thing is how information is structured and how easy it is to get to it; and from that point of view I am very pleased with the new website. It's a lot easier to read through than the old one and a lot easier to find what you need.
The old site looks way better for 'information consuming' than the new version.
My two cents.
It's a really good start though. I'm heartened to see the site get some love.