PHP is Good, Actually
2022.07.28
Okay, haters. You know who you are. I work with a bunch of y'all 😛
I'm here to explain why I, a professional web software developer, in the year 2022, continue to defend PHP.
PHP is easy to learn
What do you need to learn in order to build and deploy a simple PHP application?
- HTML
- PHP
- FTP or Git
- Basic programming concepts
Contrast with what you need to learn in order to build a simple React application:
- HTML
- Javascript
- React
- npm / yarn / pnpm / some other package manager
- Webpack / Parcel / Vite / some other build tool
- Git
- Production build / deployment pipeline
- Basic programming concepts
- and probably a little CORS
PHP is an excellent on-ramp for the web development journey. You can start with basic templating and then add complexity as needed and desired. You can get your first site up really, really fast, which is such a thrill when you are learning something completely new.
PHP is flexible
You can just use PHP as a templating language.
You can expand and just do procedural stuff, like taking some data and looping through it to echo rows into a table, or get fancier with object-oriented application logic.
You can write pure functions or wallow in side effects.
And it all plays well together, so you can build, learn, iterate, and update without having to overhaul everything. As a playground, it's fantastic. If you just want something that works, it's excellent. And if you want to be able to pick the best paradigm for each part of your application while keeping it all in the same codebase? Knock yourself out.
And if you need more? Dive into javascript and add it on top. Build it from scratch, or take advantage of the endless world of javascript libraries and code samples.
PHP is mature
PHP has been around for a while. If you keep writing code the same way you did twenty years ago, it will keep working. There are new things, new ideas, new features, new methods, but they're just recommended, not breaking changes.
If you want to take the time to learn something deeply, over months or years, without the whole landscape shifting underfoot, PHP is a good option.
And with that maturity comes a lot of other benefits: excellent tools, cheap hosting, extensive documentation, bottomless examples that work now, and will likely continue to work for the foreseeable future.
PHP has simple tooling
No webpack.
Some days, this is my number one sales pitch for PHP: you don't have to compile, transpile, or build. The file structure on your development machine just needs to get copied as-is up to the server, and everything will just work.
There are few things that can go wrong, and most of those are just ensuring that your local machine is running with the same PHP settings as the server. Once you're set up, you will probably never have to think about it again.
PHP is a good tool for many common jobs
There are jobs that I wouldn't pick PHP for. Like, my day job, building enterprise apps with complex business rules, mountains of data, and a rotating cast of developers moving from project to project? Nope, not a good fit for PHP. We need the strict, complex type checking you get with something like C# or Typescript. That alone is a deal-breaker.
But most of the internet is not big, complicated applications. Most of it is blogs and brochures and menus and meet-the-team pages. It's wikis and sharing stupid gifs and simple CRUD applications. PHP is excellent for that stuff.