PHP just celebrated its 25th anniversary. In our days of flashy frameworks coming up every other month, it’s not surprising to see tech evangelists calling for the death of PHP — since last few years, but it’s still strong with around 78% of the known web using it.

Photo by Florian Olivo on Unsplash

Bjarne Stroustrup, the creator of C++, has a quote here:

There are only two kinds of languages: the ones people complain about and the ones nobody uses.

Every language has a set of features that give you the uneasiness, you either make a compromise or create your own. If you choose to pick another language, you are back to square one. It’s a compromise always, just look at your own code and own favourite language and tell, if you don’t have any complaints about it. (Language zealots stay away.)

Back to the point, I still use PHP because it does its job and does quite well. It’s simple to set up and get it running, with not much maintenance or hosting costs. Running PHP code is the cheapest way of getting a web-app online.

Most websites and mobile-apps I have made over the last few years have relatively simple requirements, have a like button, have some comments, simple UI to add content etc. All of these easily done using PHP.

PHP has frameworks and library bindings for many things, it’s easy to play around PDFs or images in PHP than in anything else I have used in other languages. Tools have been existing for years in PHP, other languages are nowhere yet near.

To be honest, most of my PHP work is over Symfony and Laravel which make a lot of tasks easier. And it is also the strongest reason why I still like to use PHP. From robust server-side templating to strong ORM support, Symfony and Laravel are an absolute pleasure to work with. Even if you design a front-end with React or Angular or Vue, there is no other framework that comes closer than Symfony and Laravel to make your development seamless.

PHP won’t work everywhere (like background workers). It’s fine for a low-traffic shopping site, but if some architecture needs background processing for example I won’t use PHP. PHP is not suited for this. I’m not selling PHP as a silver bullet.

While PHP also performs poorly with many concurrent users but that’s not a significant number as others claim. You may get around 10–20% performance gain with other languages. Assuming performance gain is linearly proportionate infrastructure usage, you now have a 20% savings in infrastructure costs. But this comes with reduced developer productivity which is more likely to cost you much greater than 20% of infrastructure savings.

Here’s my simple rule of thumb:

  • Simple site with a contact form → Use PHP
  • Simple shopping site, content-driven side → Use PHP
  • Simple REST API backing web or mobile app → Use PHP
  • Needs complex background tasks, specialized domains (like machine learning) → Use what’s best, divide into micro-services etc.

Yes, PHP has its ugly parts — API quirks, weird bugs, Legacy PHP, Frankenstein of imperative and object-oriented PHP makes me puke. Also as with every popular language, there will be some bad code written by mediocre developers (these are the bunch who then go and cry why PHP is bad). But if you are starting a new web project, give PHP a thought, it will make your life much simpler.

Computer Whisperer. Open-source contributor. Find me at https://amitosh.in/