Languages I’ve Learned, or Not — Rethinking PHP, Slightly

Michael Gant
May 23 · 5 min read

In my 20+ years as a professional software developer, I’ve learned a variety of languages and tools. Of course, there are many more languages and tools that I’ve chosen not to learn, or never had the chance. Regrets? I’ve had a few…

Photo by Kobu Agency on Unsplash

In my article about what I would loosely call “Web 1.0”, I had some thoughts on PHP:

I can’t help feeling like the time for me to have ever learned PHP has passed. I understand that PHP is a general-purpose scripting language, not just a HTML templating tool, but it’s hard for me to get past seeing it that way. I don’t need a templating tool on the server, because any kind of dynamic UI happens in the client now. Server-side non-UI doesn’t seem to be a particular strength of PHP either. So no disparaging whatsoever if you love it, but I can’t think of a reason to try to.

I think everything I said there is true. Web development now is rich client side + back-end services. The days of building a big presentation layer on the server and serving it to the client as HTML, then rebuilding it on the server and serving it again with every change, those days are over.

That is, at least, for some definition of “over.”

Like, if there was some cataclysmic global event that resulted in the complete loss of all websites (but not the tools to build them). We wouldn’t rebuild the web using LAMP. I guess.

Actually, yeah, we probably would, because WordPress.

PHP is easy to learn and use, but not necessarily easier than a lot of other things. And many of those other things are easier to use later, when you’re maintaining the application, not just now, when you’re cranking it out. So I don’t think ease of use is why PHP is so big. I think it’s all about WordPress. WordPress powers much of the web, and PHP is how you do anything interesting with WordPress.

A different perspective

So I was watching YouTube the other day, and…

Let me back up. I’m working on an open source project right now, a quality management application for manufacturers. (Feel free to check it out, but it’s early stages.) I want to include several versions, including a basic desktop application (using Microsoft Access, if you can believe that) and also a full-blown “enterprise” version based on React, Express, and either PostgreSQL or some NoSQL variety. But I also wanted a kind of middle option, one that would be approachable for organizations that had some level of IT infrastructure and expertise, but not necessarily the scale to benefit from an enterprise version.

My initial thought was ASP.NET MVC, but then I started musing on whether PHP might be a good option, and also looking for things to watch on YouTube, and so I decided to search for “PHP,” and up comes this really great video by Hitesh Choudhury on PHP in 2019. Hitesh’s big point is that if you are a freelancer (which I sort of am) who wants to make money (which I definitely would like to do), you can’t simply ignore PHP.

A look at job postings on Upwork or backs that up. Search for web development jobs, specifying the framework of your choice. You’ll get back a “did you mean PHP?” and a whole bunch of listings for WordPress work, using PHP and MySQL. It’s just that big.

“Sokath, his eyes uncovered!”

So I decided to go with PHP for the mid-level version of the project. And since most of the buzz right now is around Laravel, I decided to check that out.

I have to admit, I was rather blown away by Laravel. It is comprehensive yet completely approachable. It includes built-in database access using either a fluent or ORM approach, controllers, views, middleware, just about everything you need. Yet despite its scope, it’s super-easy to jump into. Needless to say, I was an instant fanboy.

And this was before I discovered that Bootstrap was included by default! And Vue! Or that you could simply eject Vue and use React instead!

But this sort of brought me full circle. If I’m going to build a single-page application, why do I need a PHP framework to do that? Like I said in my original article, server-side non-UI isn’t a particular strength of PHP — Laravel makes it nice, but I think Express is nicer for that particular task — and if you use Vue as your view, that’s basically what you’re doing. I mean, it’s not a bad approach by any means, and it’s all in one place, and if you’re a experienced PHP developer, it’s a great way to transition to a more “JAMStack” approach if you find that a worthwhile goal (which I do). But I’m not seeing a compelling reason for a developer who’s not already invested in PHP to choose Laravel + Vue.

So I didn’t. I chose to use Blade, the excellent, easy-to-use templating language built into Laravel. I’m building my HTML pages on the server and serving them to the client fully-formed. For this version of the application, for the people I hope will use it and find it useful, I think that’s the right choice.

Looking inward, then forward

I have to say, I’ve been afflicted by a little bit of elitism (what an elitist thing to say! “Afflicted”, as though elitism were something that happened to me) on the subject of languages and frameworks for web development. I’ve invested a lot of time and effort in understanding how things work, as deeply as my limited brain can comprehend, because I know from experience that an understanding of the fundamentals and inner workings of my tools leads to a better end result for my users. But at times, I’ll admit to a certain overweening derision for those who just make things work — “cargo cult” programmers used to be a common term — without bothering to give much thought to the best or most correct way to solve a problem.

Maybe that’s why PHP never appealed to me. It’s never been about the best or most correct way. PHP’s strength is getting things done.

And… I guess that’s why it still doesn’t appeal to me. I haven’t really changed my mind about PHP. The industry is moving away from server-side HTML templating tools. The people behind Laravel are clearly some really bright folks and are obviously in touch with the soul of the PHP community. Building support for Vue right into the Laravel framework suggests a recognition that traditional PHP is the way of the past.

It’s also a huge factor in the present, of course. So I’m going back on what I said, at least a little bit. The time to learn PHP isn’t completely past. It’s never going to be my first choice, but I can see it’s a valuable tool to have in my toolkit, for the time being anyway.

Michael Gant

Written by

Principal consultant @ ClearEye Consulting