65 comments

[ 3.3 ms ] story [ 162 ms ] thread
I’ll save you the bother of reading 966 words:

No, it’s not.

To me, it’s never been a better time for PHP.

Recently I was asked to help out with a PHP project for work, I made the switch to rails almost a decade ago & haven’t looked back since so I was excited to see how PHP felt.

I was fairly impressed with how easy it was to jump back to PHP, the documentation is full of examples, there is composer for package management and it has a strong community who meets up regularly.

Exactly. Composer is key here. Pear just didn't work well as a third party bolt on. As a result monolithic frameworks such as Zend Framework were born, along with Blogs, come CMS come frameworks. And Rails clones. It's still hard to navigate the 3rd party landscape, but integration is so much easier.

My main gripe with Php is editor support. Jumping around a code base is hard when you introduce slightly abstract class loading. The more 'typed' the language is, I guess makes editor help easier, with auto completion etc. But that is a disjoint or me.

Editor support for functions is useful. I'm slightly embarassed still at the frequency of my manual lookups.

Class autoloading is nice, but functions are left by the wayside on the autoloading front, which is a bit gnarly.

The language is actually quite quick to learn, and you can hold a lot in your head. You can do a lot just with arrays and foreachs, without having to reach into convenience functions.

Most of my time is laboured over other frameworks and interoperability, rather than any really worry about Php itself.

> My main gripe with Php is editor support. Jumping around a code base is hard when you introduce slightly abstract class loading. The more 'typed' the language is, I guess makes editor help easier, with auto completion etc. But that is a disjoint or me.

If you are comfortable with IDEs, I strongly recommend PHPStorm. It is the one piece of software that I happily pay for each year. It increases my productivity and quality control to such degree that I wouldn't want to write PHP code without it.

> Editor support for functions is useful. I'm slightly embarassed still at the frequency of my manual lookups.

I've been writing PHP for 10 years now, and I still have to look up just about every function. I only recently discovered that PHPStorm supports displaying the PHP manual as you type, but that it is disabled by default.

For me PHP is exactly like IE6, it completly shaped web programming as we know it, and will have a true resilience, before dying, inevitably (disclamer: I used PHP from 2000 to 2009 , then switched to rails on a daily bases).
You may want to take a look at Laravel.
Sorry, I did. I made a quick return to PHP in 2016, being so happy to try Laravel on a real big project. So ... just pure disappointment ;( ;(

It is 4 time more verbose than rails and not fully compliant. Laravel is purefect for people knowing only PHP, it is a real nightmare for rubyist. ;(

And when you understood how it works you may want to try Symfony. Laravel also uses some of their libraries.
No.

As much as everybody likes to hate on PHP, it powers a lot of services that are used all around the world - and a lot of internal systems.

With 7.3 it seems as though PHP has finally got to a point where it knows who it is and where it's going - don't get me wrong, it's paid my wage for the last 18 years - but it's also made it very easy to shoot myself in the foot.

With frameworks like Laravel and Symfony about now, I can only see it getting stronger.

(Although I'm moving to more Elixir and Phoenix, I still pick PHP for simple projects, or those that I can't use Elixir on - and obviously maintaining and upgrading existing things)

Even if php stopped being used in all new projects today, people are still hiring for cobol projects.

The number of php projects now is orders of magnitude more than cobol in it's heyday.

There are going to be plenty of php jobs for quite some time.

Probably true, but also COBOL usually encodes the business logic, which is much harder to throw away and rewrite from scratch, than any presentation layer written in PHP.
>With 7.3 it seems as though PHP has finally got to a point where it knows who it is and where it's going

I've been reading a similar sentence for each version since 5.6. Is 2020 also gonna be the year of the Linux desktop?

> Is 2020 also gonna be the year of the Linux desktop?

Of course. Every year is the year of the Linux desktop! :D

It’s exhausting seeing these kinds of discussions. The only people who think PHP is dying is those who don’t use it. Besides the languages quirks, it’s incredibly productive and has a huge community of well engineered libraries for almost all mundane tasks. Theres great testing tools and general quality tool alike PHPStan. There’s an enormous pool of talent to hire from.

I code mostly in node nowadays, not through choice but due to the language snobbery I encountered during the last few years. It’s a shame. I find myself far more productive in the synchronous model than trying to bend my mind backwards with closures and async issues in the node world.

There are other languages receiving way more praises like Python that at the end of the day are just lacking so many features that php gets right but still php is the bad guy.
Like what features?
types? interfaces?
Types, sure. PHP 7 does those better than python, mainly due to the fact that the main implementation actually checks the types. Python seems to rely on 3rd party tools for that for some reason. Dunno if they're gonna change that or if they designed it like that.

Interfaces, hmm. PHP took its whole OO almost directly from Java, which is an odd thing to do given how different the typing disciplines of Java and PHP are. Python's OO system is much more in-tune with the dynamic aspect of the language.

let's say that the only advantage of python over php are ML libraries but porting a library is far different job than creating an ecosystem
yet if you want to start using python for large projects you have to come up with some hacks to make sure certain things are in check. With python is as easy as php to create spaghetti code and the language itself doesn't even help with that, however php is the only one taking the blame
Python doesn't need interfaces because it's duck-typed. If by types you mean type-hints you can have em since 3.5. It's not as pretty as TS or even PHP with strict_types=1 (even though you can describe things that you can't in php) but it works. What Python has over PHP is strong typing, meta programming, data science and ML libraries. And from what i've seen better overall code quality if you pick random library from pypi compared to packagist
Well, many of the Python fans are fresh graduates. They have been taught python because it's an easy language - no proper classes, little use of design patterns, coding standards and so on. The reality is PHP is still a thing, and will be a thing for a long long time. There is a package for anything you need in composer, and unlike most python libs, these have been tried and tested in production far longer.
>The only people who think PHP is dying is those who don’t use it.

That is absolutely not true. I didn't care about PHP at all when I didn't use it. Then I got a job where I had to use it (and the management didn't want to hear about changing it), and I started slowly disliking it. Then I got out of that job and again mostly forgot about it and curretly don't really care what happens to it.

Weird defences like yours resurge the dislike, so there seems to be some amount of lingering trauma. And of course there's the worry that the more popular PHP is, the more probable it is that I will have to face it again some day.

So, given you "don't care what happens to PHP", I assume you don't give much heed to whether it's winning or dying. That's basically what @deanclatworthy is saying, so there is nothing to fight about. Cheers!
I'm not fighting, I just gave a single data point that invalidated (logically, not actually) one part of his argument (the one I quoted) :) And then a bit of commentary.
The argument isn't that every person not using PHP thinks it is dying. As such, I don't see how your response invalidated it.

Also, the statement "that is absolutely not true" should probably be backed up by more than your single data point.

Without giving a hint on the market share of PHP in the future, I think it tells something about its attraction force.

I mean, I didn't coded much Ruby over the last months in professional projects, but I am still interested with its evolution because it was such a delight to use it with Rails.

Regarding PHP, well, I did some in the past, and my next professional project include to deal with a PHP code base. In the meantime, I didn't care to use it or look at how it was evolving, which is "as exciting as your toothbrush" innovations.

The more accurate statement would be: The only people who think PHP is dying is those who is not using it

I had a similar experience as you. I used it for a couple of projects for a 1-2 years. When I realized PHP was an overpowered template engine, I started to think that it will be dying and moved on.

> Then I got out of that job and again mostly forgot about it and curretly don't really care what happens to it.

Yet you made an account here today for this story to tell people how you don't care and why python is better than PHP.

Are you sure you don't care?

It is the same story for C++ and Java and they aren't going to die.

The more popular a language gets, the more critics it receives. Partly happens because you will see more mistakes and bad quality code which also reveals bad design decisions in the language itself.

Some languages have more quirks, especially if they are older and tend to stay backward compatible.

Scala was known as a well-designed language (I believe still is) but as the community has grown, the number of complainers also has grown at the same speed. we learned people can write horrible code with implicit conversions.

But you need those critics to detect anti-patterns, and bad APIs and hopefully either the language itself or some libraries will fix it for everyone.

It's like Quora.com:

- Is PHP dying in 2019? (25 Oct 2018) - Is PHP dying in 2018? (27 Apr 2018) - Will PHP die out in 2017? (24 Mar 2017) - When will PHP finally die? (13 Feb 2017)

I asked people at Metaculus (a forecasting website) "When will PHP die?". The current consensus out of 43 predictions seems to be 50% chance before Jan 2037, 75% before Feb 2051. Seems like a reasonable prediction.

If you are interested in making your own predictions: https://www.metaculus.com/questions/1691/when-will-php-die/

According to this interesting Google Trends chart

https://trends.google.com/trends/explore?date=all&q=python,p...

Python is on a quite strong climb, with PHP falling significantly over the years. But, it also says Javascript is on the same trajectory so that shows the real value of the data.

The chart isn't interesting. You don't know if ppl who types python, typed it to make websites. Same with Javascript, you can do an entire website but also an native apps or just a modal.
There are many fresh graduates coming out of uni thinking Python is the next big thing. But once they realise companies don't want to invest in re-inventing the wheel, they will one way or another have to learn some PHP.
If effing C and COBOL are still around and Javascript somehow turned popular as a general purpose application language then PHP isn't going anywhere.
C is coming back. Seeing rust is rising and its interoperability with C is pretty nice.

JS is almost general purpose these day. Just a bit more push to optimizations on JS engines.

This whole article reads like a search engine optimisation piece.
Upvoted because 1. you're funny and 2. it's true
Curious on how much of the 34% actually uses PHP >= 7.

As long as there's legacy, PHP jobs are not going to run out for sure, that's a given. I wouldn't exactly mind carrying a project in PHP >= 7, but I wouldn't wish to get a job in PHP < 7 territory personally.

Looking at the WordPress statistics, about 60% of WordPress websites runs on 7.x. I can imagine for dedicated servers that run PHP frameworks, that percentage is higher.

https://wordpress.org/about/stats/

Rails developer based in the Netherlands. I wish there were 50% as many Ruby/Rails jobs as there were PHP jobs here, mainland Europe is crazy about PHP for some reason.
I've been really impressed by the performance improvements made during the last couple of years. I guess my main issues with the language is the non-uniform naming of functions and the ordering of their parameters.

At some point, I'd like to see a new major release that deprecates all of those old problems in order to clean stuff up. Even if it means breaking backwards compatibility a year or two later on.

It turns out, however, that such things aren't easy to handle. Python 2 to 3, anyone?

Differences in naming & parameter order for the PHP standard library functions are because they are usually just a thin layer above a C library, therefore are consistent for that C library (e.g. string functions), but not between libraries. Would it really make sense for PHP to standardize between C libraries?
Yet another reason I don't subscribe to Medium

Medium wanted to charge me for that advertiorial crap by means of a subscription.

As far as prominent products, besides WordPress, Facebook, and Wikipedia, Slack and Mailchimp are (were?) also PHP. (I googled and apparently a prominent '-hub' site uses it too.)

The PHP hate never made sense to me in the context of the rise of Node.js:

* In PHP I've never accidentally combined 2 + 0.3 into 20.3

* I dislike the cowboy-ish over-use of ternary operators and short-circuiting by JS devs (random example from StackOverflow: var bar = data.bar !== undefined ? data.bar : 'default'; )

I appreciate that JS has functional-programming aspects that make it appealing though.

It's interesting that when PHP alternatives like Rails came around I saw a lot of anti-Java sentiment online, but now when Rails-based companies have to scale they end up using Java or JVM-based infrastructure. So trendy online sentiment shouldn't really inform best practices for various teams at various stages. (I notice that a lot of NoSQL hype seems to have died down since 2015...)

Perhaps the best commentary about why people succeed with PHP is this HN comment from a couple years ago: https://news.ycombinator.com/item?id=12704094

If you're programming in PHP, you're not running around talking about "convention over configuration" giving talks, or trying to make your code beautiful... You're incorporating feedback while the other guy is just starting to get to work. When he finally fails, he's used up half his runway, whereas you, the guy who didn't give a fuck about your code has gotten past that first failure, and are finally getting some traction.

as my friends will attest, I'm not the largest fan of PHP.

But it's not the language it was, it's much better these days; and it was always very fast for an interpreted language.

I really cannot agree with you more that for all the hate PHP gets, javascript is a thousand times worse. I figure the major difference is the ecosystem surrounding javascript. The tools are super great and writing multi-threaded/async code is very easy.

But I say this as a person who avoids both PHP and Javascript, so I might be talking nonsense.

I have being using PHP since it was call PHP - Personal Home Page. The best part of the PHP is the templating! It makes a lot more sense then Perl at the time. Now days templating can easily be replaced by EJS.

Personally I wouldn't want to use any language that does not have closure and function as a first class citizen. It makes programming fun and productive.

BTW, the 2 + 0.3 thing you are mentioning are all fixed by ES15 and ES6.

> BTW, the 2 + 0.3 thing you are mentioning are all fixed by ES15 and ES6.

Meaning that they broke a lot of code when they did that.

Not that it matters that much, since it often impossible to build a JS codebase that is over a year old without major refactoring.

> The best part of the PHP is the templating!

I've used PHP for about 15 years give or take, off and on. Before that I variously used Perl, ColdFusion or ASP for fairly routine Web services. Mostly I use PHP for straightforward CRUD work, for which it is very well suited. I'm currently using it for what is effectively a glorified CMS system. It's perfect for the task, I essentially never encounter something in PHP that causes me consequential problems within the lane that I'm using it. Although had they not dramatically boosted performance with the 7 releases, I might have opted for something else at this juncture.

> * In PHP I've never accidentally combined 2 + 0.3 into 20.3

But PHP thankfully combines `md5("PHP") + 1` into 3. Sounds legit.

I think Slack's own anecdote [1] is a better characterization of PHP nowadays. Hint: they don't disagree that PHP was (and to the lesser extent, still is) a terrible language.

[1] https://slack.engineering/taking-php-seriously-cf7a60065329

Could someone please explain both the 2 + 0.3 and md5("PHP") + 1 thing?
Autocasting. Autocasting was a cool and newbie friendly idea in principle. It just turned out to cause such horrible bugs in real code that no sane person would still argue its merits.

It also leads to stupid notions of thruthiness (google Gary Bernhard's WAT talk) and bad junior dev behavior. I've seen a popularish PHP framework document the return value of a function al boolean, but the actual return value was the string "0". It wasn't even a by prduct of the implementation. They just explicitly used return "0" for no good reason.

Facebook forked PHP (Hack) and slack transitioned to hack (or is still in the process of). Mailchimp seems to be looking for Go programmers for backend work, so not sure that PHP is the major language of their stack anymore. So not the best examples.
"but now when Rails-based companies have to scale they end up using Java or JVM-based infrastructure." Ya, Shopify begs to differ with you on that one. It's trendy to migrate a dynamic language to typed one because that's the first thing some CTO's who came from typed background want to do...it's hardly about scaling imo. Isn't Shopify proof Rails can scale?
pornhub is 100% PHP. some URLs don't even hide the fact that they are .php scripts.
I feel like I see this topic pop up every few months, pretty tired, and the article itself doesn't offer anything new or worthy data...

I feel that PHP is here to stay and future releases like 7.4 and 8 are going in the good direction. I'm pretty happy with the health of the ecosystem and how the language has improved over the last years.

It’s not dead but there’s no point in learning it if you don’t know it already. Pretty much every language used for web development is better than PHP. Python is more consistent and has better support for async code. JavaScript can be used on backend, web and mobile, Java and C# are faster and have better typing
Javascript better than PHP - I doubt. There are several solution for having Node.js style PHP too and they are doing great, see reactphp and alike
I'm not sure I'll start a new project using PHP these days (though the latest Symfony is very good), however I still frequently uses it as a scripting language, as an alternative to Bash. It's perfect for this, easy to use, and can scale to large scripts if needed.
I'm hearing a lot of praise for PHP frameworks such as Laravel, but I'm not sure PHP should strive to become more like RoR and Node.js. Rather, PHP's unique selling point, for me anyway, is its use as embedded language in otherwise static HTML pages via SGMLish processing instructions (`<?php ...>`), and I think there's nothing wrong with that even with the current preference towards Ajax and (micro)services. It's just that embedded PHP did such an incredibly poor job (like, not even an attempt) of preventing injection attacks despite SGML having very strong mechanisms for context-dependent escaping and markup validation. Which has given PHP its bad rep as a botnet/DDOS vector, and deservedly so since this has become a long-standing problem for PHP and non-PHP sites alike.
Mixing PHP, SQL and HTML is ok for 200 lines apps. It does not scale to even 10 000+ lines of code and no one is doing that anymore.

Some people are still using PHP just as a template language, but there are still issues with XSS, that one could avoid by default with dedicated template languages like Twig.

Current main selling point of PHP are great frameworks and ecosystems, easy to find developers, and share nothing architecture that removes whole class of problems related to memory leaks and scalability.

Like many I've worked in lots of languages over the years and enjoyed the benefits, challenges and quirks of each one. But when I want to get a web application idea up and running I almost always reach for Laravel. It's the cleanest and most feature-rich application framework I've come across. I don't really care that it's written in PHP. All I know is that it's rock solid and gives me tons of infrastructure built-in. (I should note, though, that for the past couple years I only use Laravel for the back-end, and Vue for the interface.)
You either die a hero, or you live long enough to see yourself become the villain.

~ Batman