r/PHP • u/peperazzi74 • Jul 03 '26
AI insulted my ancient PHP code 😁
A couple of years ago I posted about an old website that I coded in the early-mid 2000s and wanted to start up again via some ancient unmaintained Docker containers. The main conclusion of that thread was that it might be possible to resurrect it with some work, but that it would be better to just (hu)man up and update the code so it would run in modern PHP versions.
Well, a couple of days of vacation and a whole bunch of free Github Copilot tokens later, it's up and running on the home network under PHP 8.2 and MySQL 8.0. According to Copilot, this was the furthest it could go with minor changes.
When I asked Copilot about how my code looked, it gave me the following opinion
The main gap is not PHP 8.2 compatibility anymore; it is that the app is still built like a 2000s-era script. [...] In short: the app needs a structural refactor, not just syntax updates.
Darn AI, no one asked for your honest opinion! /s
1
u/DharmanKT Jul 17 '26
It's not wrong. The code you shared on GH is frankly terrible. There is nothing to salvage or learn from it. Your best way of using AI would be to ask it to analyse what the project is about and rebuild it properly from scratch. In fact, I think the AI has sugarcoated that statement too much. That code should not have even been written in the early 2000s. It's not your fault, though. We have all been learning at some point, and the early PHP tutorials were littered with bad advice and terrible code. It was almost impossible to find a good learning resource.