- ramblings php dx
Note: This was originally posted as a Mastodon thread but since my posts there auto-delete after a while I decided to keep a a slightly modified version here too.
The other day, I read this post titled What We Lost with PHP and jQuery.
I never really was a PHP developer. I dabbled a bit, sometime around PHP 4.2 or so. I didn’t particularly like it. I checked in once with PHP 7 for some hackathon-type thing, and it had gotten much better already.
The article resonated with me, and I had a few hours to kill, so it was time for a little exploration.
#The experiment
I started with catching up on PHP development from 7 to 8.4. I had no major complaints, it’s a pretty usable language now. I’m still not a big fan of its syntax and, more importantly, some of its APIs, but you know what, none of that’s a dealbreaker. The list of changes and improvements over the years is quite impressive; this is no longer the PHP it was popular to make fun of:
PHP Version History: Brief Timeline of the World’s Most Used Backend Language
To get some hands-on experience, I cobbled together the to-do list app example that many modern frontend frameworks use. This was the stack:
- PHP 8.4, no framework.
- A bit of HTMX for that modern SPA feel, directly from UNPKG with no build step.
- FrankenPHP as webserver/PHP runtime.
Everything was in one file of ~200 lines. PHP code at the top, HTML with some interpolated PHP on the bottom, CSS in a <style> element:
<?php
declare(strict_types=1);
// PHP code
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- more head elements -->
<style>
body { ... }
/* more css here */
</style>
</head>
<body>
<!-- more body elements here -->
<div id="todo-list" hx-trigger="htmx:afterRequest from:form" hx-get="?fragment=stats" hx-target="#stats">
. <?php foreach ($todos as $todo): ?>
<?= renderTodo($todo) ?>
<?php endforeach; ?>
</div>
</body>
</html>
A bit strange at first, but in the end not too different from e.g. a single-file Vue component.
#The verdict
To my surprise, the whole process was rather enjoyable, even as someone who is not particularly familiar with PHP: no frameworks, no build process or bundler, file-based routing, automatic restarts on changes during development with frankenphp php-server --watch. Also easy to deploy, either on a shared host or a stupidly simple Dockerfile (documentation).
Would I use this for a bigger project? Almost certainly not. But I could see myself doing this for something small, where the “backend” isn’t particularly sophisticated and where even just thinking about bundlers and build processes and all that jazz would probably kill my motivation before I even got started.
#The takeaway
I’m glad I did this. It’s good to look outside the ecosystems you use regularly. And the post I linked at the start of this thread was right: it did indeed feel like we lost something, mainly the ability to just write code and get things done, without layer upon layer of incidental complexity on top. It’s not only about getting things done either, it’s also about how approachable our industry is to newcomers. Learning programming is hard enough without also having to learn about all these other things, and I’m afraid we’re losing a lot of potentially great people because of this. Writing software can be an incredibly rewarding and stimulating experience, and I want more people to be able to experience this. Let’s say no to overly complicated stacks and treating every side-project like it’s the next unicorn and embrace simplicity and having fewer barriers between an idea and working code.

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.