The other day a friend of mine told me a story. He shared that he was meeting new colleagues at his new job, and when asked about his background, my friend told him that he’d been programming PHP for 18 years. My friend’s new colleague said “I’m so sorry.”
We laughed, because it’s funny. When you’ve worked with PHP a long time (about the same for me as my friend), you sorta have to. We know the language is warty and lacks uniform design principles. We know the process of creating it is sometimes an anarchic mess. We also know that it’s really, really good at solving some problems, and that’s why we still keep using it.
A few years ago, I hit a crossroads. PHP and me, we weren’t seeing eye-to-eye. I had been dabbling in Node.js and Python, and I liked what I saw, particularly a couple things:
- Easy to use package libraries like
npm
andpip
that had lots of well-written, interoperable components - A fair bit of emphasis on simple solutions for specific problems: built-in simple web servers; straightforward module systems; basic, usable testing libs shipping in the standard library.
To compare, this is what I saw in PHP:
- Lots of monolithic frameworks that were not interoperable
- Complex solutions (like monolithic frameworks, complex ORMs, etc) that tried to fit as many use cases as possible
- Lots of difficulty finding high-quality libraries of code unless you bought into one of those monolithic libraries. PEAR existed as a package manager, but there was not an active central repository where people could publish their work
- Downloading code in ZIP files from Google Code or SourceForge. God help us.
This sucked, especially if you felt, like I did, that having to learn a big fat framework and inherit a ton of code was a crappy idea. I started yelling about this with a blog post I titled “The MicroPHP Manifesto”. Some people seemed to agree.
I was still thinking about jumping ship, probably to Python, because that was where my work was headed. I did for a while, actually. But then I came back.
I came back because the good stuff was still good, and the bad stuff was starting to get a lot better. Now, a couple years since, I am even more confident that I did the right thing, and there are three major reasons why.
Composer and Packagist
I’ll say it plainly: I think Composer and Packagist saved PHP. Yeah, it still would have been used for a long time for WordPress and Drupal and some other very popular systems, but outside of that I think PHP was going in a bad direction, and I think it was Composer that saved it. It saved it because it gave great motivation to developers to create high quality, interoperable libraries. It did this by making it so much easier to find these libraries via the Packagist system. Discoverability was a huge problem that led people to keep choosing frameworks that gave them everything in one place. Composer & Packagist meant you could find what you needed, and only what you needed, quite easily. This was the biggest technical reason I came back.
Community
I should say here that I mean the non-application-specific PHP community that I run into mostly at conferences, because if we talked about everyone who worked on PHP stuff, it would be a hundred times bigger.
I haven’t run into a cooler, less clique-ish, friendlier community than the PHP community. Maybe it’s because we know our favorite programming language is not all that pretty, but it works really well. There is very little pretension with PHP folk, and I love that to death. We’re just trying to make good stuff and share what we know. It’s a really great open source community, and I am extremely proud to be part of it.
Diversity of Ideas
You could also call this “PHP’s willingness to liberally steal ideas from other platforms.” If there’s something that works pretty well on another plaform for web app dev, there’ a good chance it will end up in PHP, either in the language itself, or in userland. Stuff like short array syntax, ReactPHP, traits, and the built-in web server all came from other places, and all are super cool in PHP. And, if PHP doesn’t provide it, we’re very willing to just use other tools, like Node.js or Python or whtever, as long as it does a good job. That’s awesome.
There’s still stuff I don’t like much with PHP. Other than the crap we all complain about like function names and parameter order, my biggest beef is that the object system is so much like a mini-Java: very rigid, not composable. Don’t like it. Wish it was more like JavaScript or Python.
But, I can work with it. I like it here. I’ll stay a while longer.