PHP is much better than you think

Fabien Potencier

July 04, 2012

Rants about PHP are everywhere, and they even come from smart guys. When Jeff Atwood wrote yet another rant about PHP, it made me think about the good parts of PHP.

The biggest problem of these rants is that they come from people stuck in the old days of PHP. They either don't care or they don't want to admit that PHP actually evolves at a very fast pace, both at the language level but also at the community level. In fact, it evolves much faster than any other language or web platform. It has not always been the case, but the last 5 years have been an amazing journey for PHP.

Before talking about the amazing things the PHP community has achieved recently, let's have a look at some interesting numbers: PHP is used by 77.9% of all the websites whose server-side programming language is known. WordPress is used by 16.6% of all the websites in the world. If you have a look at the top three CMSes, for the websites that use a monitored content management system: Wordpress is first with 54.3%, Joomla is second with 9.2%, and Drupal is third with 6.8%. Three products written in PHP.

PHP must have done something right, no?

Now, let me tell you a secret, the PHP "tour de force": Despite the changes over the years, PHP is still the easiest language to learn for non-technical people: it allows anyone to create dynamic websites faster than with any other technologies, it allows anyone to host websites cheaply and without any hassles. PHP is probably not the best designed language in the world, but it lets you get things done, and you can't argue with that.

PHP, the Language

PHP 5.0 (released in 2004) brought us a very solid object model... wait a minute, I'm talking about something released almost 8 years ago. Fast forward now. The latest PHP release, PHP 5.4, comes with all the bells and whistles you might dream of in a modern web language: yes, PHP supports namespaces; yes, PHP supports closures; yes, PHP supports traits.

It took some time, but PHP 5.4 also comes with some nice syntactic sugar that makes the whole experience better than ever: yes, PHP supports [] to define arrays; yes, PHP supports calling a method on a newly created object ((new Foo())->bar()); yes, PHP supports getting an array item from any expression ($foo->bar()[1]).

PHP has even learned from its mistakes: register_globals and magic_quotes are definitely gone.

Last, but not the least, PHP even comes with a built-in web server that eases local testing... and it starts in a matter of micro-seconds.

Next challenges: How do we "upgrade" all the old tutorials talking about PHP on the web? What is the best way to support the WebSocket technology in a PHP application?

PHP, the Ecosystem

Having a good language is great, but having a great ecosystem is even better. And the PHP ecosystem has evolved a lot in the last few years.

Git

I won't talk too much about this one. Git is everywhere and PHP embraced Git pretty fast. Almost all major PHP libraries, frameworks, and products are now using Git, including PHP itself.

Composer

Two years ago, I wanted to get rid of my ugly-PEAR-hack I did in symfony 1 to support plugins. I wanted to replace it with something that was able to manage project dependencies, not a global installer like PEAR. Managing dependencies is not an easy task, so I tried to find the best algorithm to manage software dependencies; I had a look at everything: from Perl to Ruby, from Debian to Redhat. Nothing was satisfactory: only homegrown solutions that happen to work... empirically. Then, I stumbled upon ZYpp. That was it. ZYpp uses a SAT solver to manage dependencies. Fast forward. Thanks to the hard work of Nils Adermann and Jordi Boggiano, PHP now has one of the best dependency manager, Composer.

Yes, PHP has a better dependency manager than any other languages.

And thanks to Git, Composer, and the PHP built-in web server, it has never been easier to download/install/test a PHP project.

Want to test Symfony (using PHP 5.4)?

$ composer.phar create-project symfony/framework-standard-edition
$ cd framework-standard-edition
$ ./app/console server:run

Want to test Silex?

$ composer.phar create-project fabpot/silex-skeleton
$ cd silex-skeleton
$ php -S localhost:8888 -t web/

Don't know Composer yet? You should learn about it. Browse Packagist, the main Composer repository: it already has 1900+ packages available and they have been installed more than a million times in less than 3 months.

Next challenge: include the Composer installer in the next PHP version?

Collaboration

Community collaboration is the most important point of this post; the one I'm the most proud of. We start to see better collaboration between PHP projects, even from the very big ones, the ones you would think are large enough to not care about the others.

phpBB, Drupal, eZ Publish, Symfony, and many others (phpDocumentor, PHPUnit, Behat, Zikula, Propel, Doctrine, Midgard, ...) are sharing code. Yes, they are "competitors" but they all understood that cross-pollination was a good thing. And Composer is a good enabler.

Next challenge: Convince even more projects to join the trend.

Conclusion

Let me say it again: PHP is probably not the best language out there, and I'm the first one to scream about its quirks, but PHP is the best web platform... ever.

Discussion

gravatar Loïc Chardonnet  — July 04, 2012 10:21   #1
It's really great to see an answer for all this smear campaign against technical points in PHP.
At last, one of the PHP star answer, and I'm glad to see that it is with a pragmatic approach rather than a fanatic one (I'm sure some will be thrilled and will debate about how PHP closure are in fact anonymous function).

Thanks for this post!
gravatar Matteo Giachino  — July 04, 2012 10:27   #2
I totally agree. In the end, community matter so much more than hype or "à la mode" syntaxes.

I must strongly disagree for the part when you say that the debian package manager (apt-get) is a homegrown solution! It's, by far, the best package manager around. Look at osx for a bad example!
gravatar Samy Dindane  — July 04, 2012 10:28   #3
"Yes, PHP has a better dependency manager than any other languages."

Would you explain why please? Compared to Bundler for example?
gravatar Julien DIDIER  — July 04, 2012 10:28   #4
PHP is permissive. And he has a really messy history.
Ok for new coding style on PHP5.4. But the prototyping could be more better for next versions.
To grow up, PHP has to change old attitudes.
gravatar Konstantin Kudryashov  — July 04, 2012 10:36   #5
Matteo Giachino:

Homebrew is the best package manager i've seen to date http://mxcl.github.com/homebrew And hey, it's on MacOS!

Aaaaanyway. Can you avoid remarks like "loot at [X] for a bad example"? What's the point of creating rants inside rant-answering post???
gravatar ?????  — July 04, 2012 10:40   #6
A very nice post, i started using PHP many years ago and i never had so much problems as some sites describes.
But i'm not sure about one thing in this ecosystem: Packagist.
Composer is a great resource and as an old fan of PEAR for its "officiality", i hope the PHP group will replace PEAR with this.

What i mean is only about Packagist: start searching for "test", "example" or look at "nervo"'s packages, it's a bin for everything!
PEAR is old and unmaintained, PEAR2 isn't a revolution, but Packagist is relatively young, how do you think it will be in a couple of years or with thousands more users?
gravatar Grégoire Hubert  — July 04, 2012 10:43   #7
PHP will have one day to leave behind its heavy legacy from the past (unconsistent API, non catchable errors etc etc)

Appart from that, hard to spot another language able to build from « hello world » to Facebook.
gravatar Damien MATHIEU  — July 04, 2012 10:46   #8
> Yes, PHP has a better dependency manager than any other languages.

What ? Are you kidding ? You clearly haven't looked at what other languages offer. Bundler is way better than anything I've seen everywhere, including composer.

> $ composer.phar create-project symfony/framework-standard-edition

I'm sorry, but that syntax is horrible.

> bundle install

I do prefer this !

> The biggest problem of these rants is that they come from people stuck in the old days of PHP.

Let me disagree. Jeff Atwood isn't stuck in the old days of PHP. He moved away from PHP some time ago, discovered what is possible to do outside of it and used it.

PHP has indeed improved a lot in the past years. But it's still far behind what many other languages offer : syntax coherence (and not some method camel cased and some other not); real objects, everywhere; big communication problems within the core team. These are the problems of PHP today.
gravatar Pedro  — July 04, 2012 10:50   #9
PHP does NOT have a better dependency manager than any other languages.
I've worked with many platforms, including PHP, and the best dependency manager prize goes to NPM, no doubt about it.
That tied to the Node.js module system makes an unbeatable duo IMO.
gravatar Marek  — July 04, 2012 10:51   #10
The main problem is that in every community there are haters. Programmers community isn't different, they are many believers of one right programming language.
gravatar Jason Hanley  — July 04, 2012 10:53   #11
"PHP is probably not the best designed language in the world, but it lets you get things done, and you can't argue with that."

Exactly. You can waste the day away arguing about "pretty" syntax, or you can sit your ass down, write some code, and create something amazing.
gravatar Fabien Potencier  — July 04, 2012 11:03   #12
I know Bundler pretty well, and I can tell you that Composer is much better. And of course, to install your dependencies, you just have to do

composer install
gravatar Loïc Chardonnet  — July 04, 2012 11:06   #13
PHP is not perfect, sure, but it's an evolving language.
Compare this with Agile methods: Some languages are so greatly designed before being written that they struggle to incorporate new changes (see http://blog.astrumfutura.com/2012/04/php-innocent-villagefolk-or-a-pillagin-pirate/ to understand what I mean).
gravatar Pedro  — July 04, 2012 11:16   #14
Let me just tell you something:
I did PHP and many other languages.
You either love yourself and strive for using something better.
Or you stick to poorly written languages and runtimes and need articles like this to convince you otherwise.
gravatar Christian Walde  — July 04, 2012 11:22   #15
> PHP supports namespaces

Do these still use the ridiculous backslash separator?

> PHP supports closures

With painfully convoluted syntax, necessitated by the fact that PHP doesn't know what scoping is. Compare:

$tax = 0.5;
$total = 0;
$func = function ( $quantity, $price ) use ( $tax, &$total ) {
$total += ( $quantity * $price ) * ($tax + 1.0);
};
array_walk($this->products, $callback);

with:

$tax = 0.5;
$total = 0;
$func = sub { $total += ($_[0] * $_[1]) * ($tax + 1.0) };
$func->( $_->quantity, $_->price ) for @products;

> ((new Foo())->bar());

Why not a sane syntax like:

Foo->new->bar;
# or
Foo.new.bar;

Then again, it DOES feel like i'm writing LISP there!

> ($foo->bar()[1])

Did you typo this? shouldn't it be ($foo->bar())[1]?

> PHP has a better dependency manager than any other languages.

Based on exactly which evidence, parameters, arguments. I challenge you here and claim that is entirely wrong. You made the claim, now i expect you to prove your claim, preferrably in your very next blog post, by making an in-depth comparison of the package handlers of PHP, Ruby, Perl and Python.
gravatar Christian Walde  — July 04, 2012 11:22   #16
And to top it off, your blog happily butchers formatting.
gravatar Robert Payne  — July 04, 2012 11:39   #17
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ is probably the best post of all the things php does that are so weird or inconsistent.

PHP has done one thing right and that is become the language that every server comes with.

If you look at the highest traffic websites in the world the ones that are using PHP are probably using Zend + some extreme customisation like Facebook.

If PHP was "The best Web Platform" more startups for big websites would be using it. Twitter, Pinterest, Github are just examples of newer big websites that do not use PHP.

Find me a banking website anywhere in the world built on PHP. Or a Third party payment processor like Paypal or Fastspring built on PHP.

I agree PHP is easy, but it is far from "the best". It could use with a very very radical clean up.
gravatar Michel Bartz  — July 04, 2012 11:44   #18
@Christian Walde: Typical comments coming from someone who has obviously no background in PHP and its ecosystem, as well as the various decisions that lead to some of the "shortcomings" that you points.

- The backslash for namespace, as much as I am not a fan of it, I'll refer you to the RFC : https://wiki.php.net/rfc/namespaceseparator and read up on it, and you'll understand why it was probably the only sane option.

- Your suggestion for closure is just unreadable, ugly, and not in line with current PHP synthax.

- Both of your proposition for the object access on new are in line with current PHP synthax.

- $foo->bar()[1] , agreed on that one.
gravatar Karoly Negyesi  — July 04, 2012 11:54   #19
The argument that hip websites are using hip languages do not go against this post. Economically (which is not something startups will consider first) PHP is the best choice because of the supply-demand PHP coders are cheaper. Yes, there are more crappier PHP coders but more masters too. That simple. It's not cool, it's not exciting so those startups do not use it... yet it's still the best tool.
gravatar Ben Sinclair  — July 04, 2012 11:57   #20
"PHP is still the easiest language to learn for non-technical people" is a bit of a broad brush.

I'm not sure where it comes from, either, as it's unqualified: certainly I'd disagree that PHP is an easier or more useful language to learn than, say, Python, from a newbie's point of view in a non-web environment. If we restrict ourselves to using a language as essentially a web template script, then PHP is fairly straightforward - virtually the same as a designer learning enough to use Smarty.

The statistics you cite combine uneasily with your closing opinion, "PHP is the best web platform... ever" - popularity is not a good guideline for quality or even ease-of-use, unless your bar for measuring superiority is skewed this way to begin with. It's pretty much equivalent to saying "Windows 95 is the best desktop OS... ever".

"The latest PHP release, PHP 5.4, comes with all the bells and whistles you might dream of in a modern web language: yes, PHP supports namespaces; yes, PHP supports closures; yes, PHP supports traits."

PHP has clearly it has improved in the last few years, but it's still badly fragmented: most non-trivial projects I've used have contained a butcher's shop of coding styles. The ecosystem you espouse is trying valiantly but if PHP wants to compete into the future it needs to draw a line in the sand and basically deprecate all the crap... and there's an awful lot of crap still to deprecate.

I wonder if by the time the big guns like Wordpress and its pals employ all the new language constructs the same problem might not just come around again? Obviously this isn't restricted to PHP, but it is probably where it's most obvious.
gravatar Sanpi  — July 04, 2012 11:58   #21
@Damien MATHIEU Read the documentation before criticize `create-project` bootstrap from scratch a project. Like bumble, the `install` download and install the dependencies.
gravatar Eurico Jardim  — July 04, 2012 12:09   #22
Articles warming hearts, like this one, are important to keep communities alive and working.

However, for those stats about sites using PHP, I could give you the latest trends on TIOBE:
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
Yep, PHP is the only one on is kind with "red down arrows"!

Don't get me wrong, I still like PHP and use it, as well as Symfony is one of my favourites. But, I just prefer Python/Django and RoR...

gravatar Samy Dindane  — July 04, 2012 12:10   #23
While I may agree that PHP is moving forward and has a great community, I'd like to mention that most of the arguments stated in this blog post are related to PHP 5.4, which, in real life, (almost) nobody uses in production and is supported by (almost) no hosting service.
Giving that most of PHP websites are on the 5.2 version, PHP 5.4 is just a cool shiny myth.

> PHP is still the easiest language to learn for non-technical people: it allows anyone to create dynamic websites faster than with any other technologies, it allows anyone to host websites cheaply and without any hassles.

I can't disagree more: that's just what people believe. Ruby is easier to learn and much more consistent, and you can write a Sinatra app and deploy it on Heroku in few command lines.
gravatar Barney Hanlon  — July 04, 2012 12:11   #24
Christian Walde: you mad?
gravatar Lukas Kahwe Smith  — July 04, 2012 12:16   #25
Lets not get carried away on of composer is the best or just on par with Bundler and NPM etc. its definitely not noticeably worse.

The key thing to learn from the fact that PHP isn't designed yet still rules the web is that the eco system is what matters. And here PHP is simply untouchable in penetration. Popularity leads to ubiquity, leads to more hands, more jobs etc.

case in point: even if PHPs syntax might be inconsistent in a few places, "easy to learn" for the most part boils down to how easy it is to find a mentor (either a physical one or someone on the web) and here again ubiquity wins over careful design.

That being said, if you get to start from scratch on your startup sure you can choose other alternatives, but expect to have to solve lots of problems that have already been solved in PHP. some people are willing and enable to afford that. and of course there are also benefits to gain from other languages (not the least of which for some is doing something different than what 70%+ of the web is doing).
gravatar Pádraic Brady  — July 04, 2012 12:23   #26
The problem, as keeps cropping up, is the people love to ignore reality.

In reality, PHP is a powerful, popular, well featured, utilitarian programming language that dominates the internet and evolves rapidly to service web application needs. The evolution of the language and its community of users has been stunning. Also, it's a pirate - you can't dump a new ship into the ocean and expect not to be picked clean by us ;). We do appreciate your booty.

In certain peoples' fantasies, PHP is a quirky, bad, poorly performing piece of kiddie nonsense that should be ignored because ignoring your most formidable competitor is a good idea.. Ruby was very good at concentrating that idea by presenting a direct challenge. It didn't work out too well.

Someday, someone will present an actual study as to why PHP is so irritating. Easy to learn, quick to adapt, lower development costs (direct labour), just as scalable as anything else, etc.

Evolution, baby. PHP is a survivor.
gravatar philsturgeon  — July 04, 2012 12:47   #27
For the folks that seem so shocked by the idea that PHP now has awesome dependency management, you clearly haven't actually used Composer.

Somebody complained about the syntax of Composer based on two examples of "How to get a whole framework running locally in 3 commands". In those 3 command situations you'll never have the CLEANEST syntax, but that is not the point - you're aiming for 3 commands and the fact you can do that means PHP 5.4 has come on a LONG way since previous versions.

Using composer "for realises" is simply a case of running:

$ composer install

I have used bundler and npm. Composer beats the living daylights out of composer and does not require RVM as the code is application specific. It is on par with NPM. Forget about PEAR everyone.

As for the "A Fractal of Bad Design", yes we've all seen it. Some of those points are true, some are out of date and some are just complaints about loosely typed languages. If you don't like weak typing then don't use a weakly typed language. It has pros and cons like everything.

Jeff had many good points, but his article lead to a call to action which wasn't really there. His point is "Stop complaining or do something useful". The fractal of bad design is a nice start for a series of Pull Requests I'd say, especially now that PHP is on GitHub.

The only other recent PHP rant that hasn't been linked to is clearly the best one: http://blog.astrumfutura.com/2012/04/php-innocent-villagefolk-or-a-pillagin-pirate/

PHP is mental. It has grown and evolved in some weird ways, but each version is getting better.

It is what it is. Ruby has some nicer bits of syntax, and so does Python, but Python has some fugly parts to it like the terrible terniary.

Every language has weird and wonderful shit in there and PHP is slowly but surely shaking off some of those weird bits and moving towards being a modern language.

To see how WTF JavaScript can be, why not take a look at WAT:

https://www.destroyallsoftware.com/talks/wat

Case and point: nothing is perfect, PHP really isn't, but it's got a LOT better in the last year and not many people are giving it credit for that.
gravatar Pádraic Brady  — July 04, 2012 12:51   #28
@Eurico, while pointing to the Tiobe index it's worth noting the long term trends (not just a single month blip). Most programming languages have been on the decline since 2008. Recession.

Objective C and C#, among the exceptions showing a positive trend, are obvious to explain.

The main two languages showing a long term decline are Java and C++ which is always expected as the younger kids underfoot take over more market share.
gravatar philsturgeon  — July 04, 2012 12:52   #29
Edit: Composer beats the living daylights out of [bundler]. It doesn't hate itself.
gravatar Derek Clapham  — July 04, 2012 13:10   #30
Fantastic post Fabien... Am about to jump off the Symfony 1.0 train (still stuck in PHP 5.2 world) and on to the Symfony 2.0 train...

Looking forward to it, will need to read up on how far PHP has come in the last 6 years...
gravatar Sam Williams  — July 04, 2012 13:38   #31
In my life I have heard far too many rubbish guitar riffs (including Nickelback), but I do not believe that the guitar is fundamentally flawed, it's the "artist" that needs improvement.

I've used PHP for about four years now, first as a hobby and now as a profession. The thing I find most frustrating about the language is the people using the language. Because PHP is easy to learn, widely supported and well... everywhere, you will have a whole range of people with varying levels of skill using the language; people from amateurs, to code cowboys (and girls ;) to perfectionists. I like to think that I write somewhere between acceptable and great code now, but when I look back at things I have developed even six months ago, I almost vomit!

PHP is powerful and easy to learn, as a community we just need to ensure that people are learning good coding practices and that old repos get cleaned up with modern techniques.
gravatar Christian Walde  — July 04, 2012 14:18   #32
@Michael Bartz:

Having *reasons* for shortcomings doesn't mean you have actual *excuses* for still having them and doesn't make the shortcomings any less of an issue. Also, less ad hominem would be appreciated.

> - The backslash for namespace, as much as I am not a fan of it, I'll refer you to the RFC : https://wiki.php.net/rfc/namespaceseparator and read up on it, and you'll understand why it was probably the only sane option.

The sane solution would've been: "Namespaces equal classnames, let's go ahead with ::." However a lack of prior sane design precludes the latter.

> - Your suggestion for closure is just unreadable, ugly, and not in line with current PHP synthax.

I disagree on the ugliness of syntax itself, but i do agree i could've made it more pretty. Consider:

$tax = 0.5;
$total = 0;
$func = sub { $total += ($_[0]->quantity * $_[0]->price) * ($tax + 1.0) };
$func->( $_ ) for @products;

Or alternatively:

$tax = 0.5;
$total = 0;
$func = sub {
my $item = shift;
$total += ($item->quantity * $item->price) * ($tax + 1.0)
};
$func->( $_ ) for @products;

The point, which you missed, being: With proper first-class closures and a good scoping model, you don't need to declare which variables from the surrounding scope ( $tax, $total ) you wish to use inside your closure, you can just go ahead and use them. PHP fell entirely flat on that count. I'll grant you though, they're not as bad as python closures, where you can only use a single statement instead of multiple lines.

> - Both of your proposition for the object access on new are in line with current PHP synthax.

They are? Between the example Fabien gave and mine i see a delta of 8 parens. Are these all optional or what?


On a lst note: Honestly not picking on you with this one, just a helpful pointer: It's syntax, not synthax. :)
gravatar anonymous  — July 04, 2012 15:25   #33
80% of all shared hosting providers support it, all database systems support it, looking for database connections all are supported etc

When I started out in Java, it was PHP vs Java, and many said it was not enterprise ready.

Well there is a saying:

"If you have a PHP problem, the Symfony community has already solved it"

More power to the PHP Hammer
gravatar Stephen Senkomago Musoke  — July 04, 2012 15:27   #34
80% of all shared hosting providers support it, all database systems support it, looking for database connections all are supported etc

When I started out in Java, it was PHP vs Java, and many said it was not enterprise ready.

Well there is a saying:

"If you have a PHP problem, the Symfony community has already solved it"

More power to the PHP Hammer
gravatar anonymous  — July 04, 2012 15:46   #35
In my personal opinion, when I read the post of Jeff Atwood, I just thought "Another guy trying get attention to his blog (get more visitors)" and well he got it, what a piece of cake... how can I get more visitors? Let's write bad things about the most used web server-side languages (77.9%), for me that was all.

About PHP, is the perfect language? no..., there is not such of thing... could have better languages or worse, but there is not the "perfect" one.

Even those that think that there are better ones, all is relative... for me PHP has a great comunity, I don't know if the biggest, and "In my personal opinion is the best", that is way I think PHP is the best language for server-side... Do you get it? is the best language due its comunity... so, there are others developers that think the language they use are the best because blah blah blah and that is okay, every one has their own reason....

I would like to remark two things about what Fabien said...

"PHP is still the easiest language to learn for non-technical people"

Of course it's, with such great comunity and information every where....I don't know if that was what Fabien meant, but is the way I see it.

"Next challenges: How do we "upgrade" all the old tutorials talking about PHP on the web? "

Exactly, there are many websites that doesn't apply the best "code", and that isn't a bad thing (at least they share what they know) is just that it could be "better" :D... But we also have that on Java, Ruby, C#..... is just since PHP is the biggest (77.9% or more) we see it more often.
gravatar Richard Perez  — July 04, 2012 15:48   #36
In my personal opinion, when I read the post of Jeff Atwood, I just thought "Another guy trying get attention to his blog (get more visitors)" and well he got it, what a piece of cake... how can I get more visitors? Let's write bad things about the most used web server-side languages (77.9%), for me that was all.

About PHP, is the perfect language? no..., there is not such of thing... could have better languages or worse, but there is not the "perfect" one.

Even those that think that there are better ones, all is relative... for me PHP has a great comunity, I don't know if the biggest, and "In my personal opinion is the best", that is way I think PHP is the best language for server-side... Do you get it? is the best language due its comunity... so, there are others developers that think the language they use are the best because blah blah blah and that is okay, every one has their own reason....

I would like to remark two things about what Fabien said...

"PHP is still the easiest language to learn for non-technical people"

Of course it's, with such great comunity and information every where....I don't know if that was what Fabien meant, but is the way I see it.

"Next challenges: How do we "upgrade" all the old tutorials talking about PHP on the web? "

Exactly, there are many websites that doesn't apply the best "code", and that isn't a bad thing (at least they share what they know) is just that it could be "better" :D... But we also have that on Java, Ruby, C#..... is just since PHP is the biggest (77.9% or more) we see it more often.
gravatar Axel Etcheverry  — July 04, 2012 16:04   #37
Portage (gentoo) is the best package manager i've seen to date !!!
gravatar its me  — July 04, 2012 16:45   #38
PHP is undoubtedly the best web platform, but rather than moaning about its quirks, WTF don't we fix them?

gravatar Steve Adams  — July 04, 2012 18:18   #39
Thanks for this Fabien. The thing that I argue in favor of php is that it transformed me from a graphic designer to a reasonably high paid, enthusiastic, contributing, productive web developer. I honestly doubt another language could have done this! It brought me into the programming world, through all the good and the bad features, and now... Well, now I'm another human being who can interact with a computer with more than just mouse clicks, who can contribute to the ecosystem you're describing, and who can aid in moving web platforms forward. This is exactly what the web needs, and php (along with its community) made it possible.

I took a stab at development with many languages before I finally stopped listening to the nay sayers and tried out php. Sure I wrote some awful code, but I could actually do it! Any smart developer can find flaws in any language, too... But it takes a smart one to utilize what's available for good (Which you have done an incredible job of in the last several years).

Thanks!
gravatar Ilya Averyanov  — July 04, 2012 18:41   #40
@philsturgeon
> I have used bundler and npm. Composer beats the living daylights out of [bundler] and does not require RVM as the code is application specific. It is on par with NPM. Forget about PEAR everyone.

Your experience is probably outdated, since bundler does not require any Ruby managers (RVM) to keep all packages locally for a specific application. Bundler does this natively.
gravatar Larry Garfield  — July 04, 2012 19:16   #41
"There are only two kinds of programming languages: those people always bitch about and those nobody uses." -- Bjarne Stroustrup

PHP falls into the first group. :-)

Sure, there's a lot about PHP that sucks. There's plenty of legacy baggage that hasn't been purged yet. There's still a too-strong procedural-think in places. PHP-Internals is still a case study in disfunction. But you know what? I've been working in PHP for the past 13 years, and I barely recognize the PHP world today compared to just four years ago.

The GoPHP5 project, Namespaces, PSR-0, Composer, loosely-coupled frameworks like Symfony, Closures, Traits... PHP today is so different than anything you're used to in the PHP world it's almost scary. Or exciting. And I really like where it's headed.

No, it's not the best solution for all situations by a long-shot. But it is a viable solution to a huge number of problems, which makes learning it, quirks and all, a very good investment because you can use it in so many different situations.

(And to Christian, I actually rather like the closure syntax in PHP, because it's explicit; Javascript's implicit closures are a ticking timebomb waiting to explode, as they do with a great deal of regularity. PHP got this one right.)
gravatar Patrick Faure  — July 04, 2012 19:19   #42
I think there is a misunderstanding there, you can't compare 'bundle' and 'composer'.

Bundler is build on top of Gem which the package manager of Ruby platform. So, it's the couple bundler/gem the complete system in Ruby.

Anyway, IMHO, trying to compare or argue that Composer is better than Gem a more than 14 years old and successful library is little bit pretentious.
gravatar anonymous  — July 04, 2012 19:39   #43
@Ilya:

I agree. RVM, rbenv, and others are _NOT_ needed to make Bundler work. In fact, certain features of Bundler overlap that make RVM useless (some Rubyist will argue with me here, but before you do, please try it first). RVM is still a good multi-version manager; however, if that is all you are using it for, then there are better alternatives that one thing and do it well. More that that isn't necessary.

I think the take-away here is that there are arguments made on both sides that are out-dated or just plain wrong. That being said, still, many of the complaints about PHP are regarding it's inconsistency and rightfully so. This can't be refuted. I see so many comments arguing "just fork PHP and fix it"...So, let me make a statement and see if it resonates with you:

"You can't fix PHP's inconsistencies because PHP's inconsistencies are what make it PHP".

While at Zendcon in 2010, it was personally asked (I have a room of at least 300 to confirm this ask) of the PHP creators if we will see inconsistencies cleaned up in future versions.

The answer was "NO"...due to the fact that this would be of little value vs. the effort it would require.

If you think this is easy, you should try it. Not only that, but once you do, I wonder what that pull-request would look like and how much wheel-spinning would go on before it finally got smacked down by Rasmus (closed without merge). Also, what do you do about PHP's lack of expressiveness? Will you write a few thousand lines of C code to fix that? How would that look? Is that really easier than personally learning a couple new languages? What about object attributes? What about instance-level extension (think traits that allow you to "use Something" on a single instance). Ruby allows that -- do you think that will get into PHP 5.4?

Even if it does, what about all the hosts that won't adopt PHP 5.3 until we have PHP 5.6 (or whatever). Isn't this the main sell of PHP...accessible hosting? What good does that do when almost none of those hosts provide you a sane version. That being said, I do know that Dreamhost does allow PHP 5.3 (they get a pat on the back).

OK, back to patching PHP...I'd love to be proven wrong, but I won't be holding my breath and if I catch you holding yours, I'll probably give you a friendly nudge as I don't want to see you die. If you don't respond to my nudge, well then, good luck to you friend.

For me, it's use PHP when absolutely necessary, and when it is not, don't.

When I do, it's version 5.3/5.4, Composer, Symfony2 components, ZF2 components, and anything other light-weight component that works for the task at hand (hopefully it uses Composer, has unit tests, and is highly modular).

I turn down any PHP project that won't agree with version 5.4 or 5.3 (over three years old). If you are a PHP developer, I urge you to demand the same for your own sanity.

If all of the good developers turn their back on crap code, process, and thinking, then the community will get better, or alternatively, that part of the community will form a new one. You might realize that this is actually already happening.

https://groups.google.com/forum/#!forum/php-standards (let the hate for fig begin).
gravatar Wil Moore  — July 04, 2012 19:42   #44
FYI, the above comment (#43) is mine. Sorry, there doesn't seem to be comment links and for some reason the above post was submitted anonymously even though I was logged in via another tab.
gravatar Wil Moore  — July 04, 2012 19:48   #45
Also, if you do php consulting, please stop allowing your customers to dictate where the final result will be hosted. This is ridiculous. They will fight you at first, but if you argue professionally and fluently, then you will get your point across.

If you don't know how to deploy PHP applications, stop taking customer's money, learn, then start again.
gravatar Tom Van Looy  — July 04, 2012 19:50   #46
... yes php can run interactively with php -a (something I use a lot and not everyone seems to know)
gravatar Christian Walde  — July 04, 2012 19:58   #47
@Larry Garfield:

I agree that from a stability and consistency standpoint the closures in default Javascript are worse. However, this is an artifact of the fact that Javascript has just as terrible scoping as PHP has. And this is where a turning point comes in:

In Javascript you can actually fix that. In Javascript you can enable something they lifted straight from Perl: Strict mode: https://developer.mozilla.org/en/JavaScript/Strict_mode#Converting_mistakes_into_errors

The day when PHP receives something like that it will instantly become a much much better language.
gravatar starenka  — July 04, 2012 20:11   #48
@philsturgeon what's so scary about python ternary?

print 'sane' if sane else 'insane'
gravatar Jason Davis  — July 04, 2012 21:28   #49
PHP haters are gonna hate, We will still shine though and lead the way in the Dev world. Great article Fab
gravatar lamine kacimi  — July 04, 2012 22:15   #50
I used to envy Java developers but since the release of PHP5, We have the entire flavor of an Object Oriented Programming Language.

PHP haters are an exception. Most of the websites out there are still running in a PHP environment.

I sometimes think that the roots of this arguing comes to a fight between Open Source and Proprietary solutions.

We are making em lose too much money; come on, of course they are gonna hate everything that's PHP #JustSaying.
gravatar Matteo Giachino  — July 05, 2012 09:22   #51
he number of posts shows that, aside of all, people really care about PHP. And this is good, we can make it better.
gravatar Mario Bittencourt  — July 05, 2012 13:39   #52
I think the biggest problem with PHP is that due to the way it has been developed (as a language) you can't rely on the fact that it will address it's problems anytime soon.

The whole PHP6 reminds me of duke and nukem forever where it is coming, coming but never comes, or like Duke a bit late :(

I haven't tried all script languages out there but if you compare the major languages (by popularity) it is the easiest one to find.

I always say that I can teach anyone with no background in web development (nor PHP) to create a dynamic website in a day using PHP. You can't say that for Java or C#!

I am not talking about making someone expert or that the code he/she will produce will be something that we will all be proud of. But it will do the job (tm).

Since the other languages (or frameworks) mentioned are newer than PHP it is expected that they've learned from everybody else's experience, including PHP, to achieve the same or perhaps better results.

But this is temporary. There is always a new feature/language that will either promise or deliver a better thing coming (Node.js anyone?)

What I really hope is that we could shake things in the PHP core team to have a more predictable roadmap addressing the problems, like consistency, that we do have.
gravatar Mauricio Lopez  — July 05, 2012 16:53   #53
I started coding a long time ago, and I am proud to say that I did it with php.

Yea, I realize now that php older versions had a lot of issues, but php and the community have envolved and continue doing it.

These discussions are meaningless. Let me do an analogy to explain what I mean.

WE (programmers) are the lord of the rings. WE are in control. PHP suits web tasks, Lua is great for gaming,
if I need more velocity , a C extension for php can fix a bottleneck, if I need a multiplatform app, Java is ok for an standalone desktop app, javascript is great for a rich user experience on the client side, etc .. etc ... etc ....

YOU ARE THE MASTER OF THE RINGS, just choose the appropriate ring for each task.

All languages have strong points and weak points. None is perfect.
gravatar Dave Twiggs  — July 05, 2012 20:01   #54
I realize there are other languages that have strengths that PHP does not have. If there was no difference there wouldn't be a need for another language. The people who love to state this obvious fact over and over are stuck in a my programming language is better than your programming language dick waiving contents. I don't want to be a part of that.

I like PHP. Partly because I know it really well but also because it is so easy for me to create my own mini-frameworks that I carry around from one project to the next. I like how easy it is to embed php inside of .css in order to make my pages more dynamic and dare I say it...fun to build.

The PHP Singularity article shows a picture of a double-clawed hammer. I have one too, although it doesn't have the nifty PHP logo on it...Sharpy here I come. The claws one one side have a larger gap than on the other side. This is designed to work with different sized nails. In my case, it is very useful for pulling up old floors that used cut square nails which can easily break inside of the floor. The point here is that it is a single purpose tool which is not always bad. In fact, the only time its bad to have a single purpose tool is when that is the only tool you have and PHP is nothing like that.
gravatar Robin Dupret  — July 08, 2012 15:54   #55
"Yes, PHP has a better dependency manager than any other languages."

Wrong. It's certainly the worst I have used. Composer is a nice way to manage dependencies but for each project we have a single copy of a project.
gravatar Gildus G.  — July 10, 2012 18:11   #56
I agre, PHP is the best, there are many programmers and developers that use or make bad practice with PHP.
gravatar yields  — July 11, 2012 03:28   #57
i registered to put this comment.

surprises me, i really adore you as a programmer, it's a surprise to me because you know, that PHP isn't a programming language, python is, ruby is, javascript is.

and i will tell you why, you probably know that but PHP
didn't start as a programmin language, it's a "tags" system.

take this for example:

js: 'Hello'.indexOf('g');
-> -1
php: strpos('Hello', 'g')
-> false

js: !!~'Hello'.indexOf('g');
> true
php: !!~strpos('Hello', 'g');
> error

that is amazing to me.

i think this is what Jeff meant when he said "PHP is a collection of functions" it really isn't a programming language.

but the problem is, it's the only tool that can be deployed just by uploading it.

and by the way, compare silex codebase to Expressjs on node, it's 20% of silex, why ? because javascript is a
programming language, php isn't.

I work every day in php and hate every second of it.
gravatar Robin Dupret  — July 11, 2012 16:46   #58
I agree with Yields ! The only point that I love in PHP is the deployment. There is, by chance, beautiful projects that works hard to provide a clean source code but it's hard to do this with an ugly "language".

For example, it took 17 years to have a peace of syntaxic sugar like the hooks for the arrays. Before, we had to write array(1, 2, 3). It's just ugly !

«I agre, PHP is the best, there are many programmers and developers that use or make bad practice with PHP. »

PHP itself provides bad code and prevent us to make a beautiful one !
gravatar Pierre Minnieur  — July 13, 2012 16:45   #59
"Wrong. It's certainly the worst I have used. Composer is a nice way to manage dependencies but for each project we have a single copy of a project."

So, all your projects share the same version of a project they depend on? Cool!
gravatar Hrvoje Simic  — July 17, 2012 15:28   #60
"PHP is still the easiest language to learn for non-technical people" is as valid argument as the following:

"Ruby is the best language you will ever see."

No really, is there a language that doesn't "get things done"? Is it a new term for Turing completeness?
gravatar Matteo Contri  — July 18, 2012 17:12   #61
Fabien, I agree with every word.

The weakness points of PHP are filled with frameworks nowadays (lack of structure, too much flexbility, etc.)

Sure in some field PHP are not so cool, but in some other no language can beat it.
The average is: the best web platform (ever).