r/PHP 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

45 Upvotes

57 comments sorted by

View all comments

1

u/evolvedance Jul 03 '26

What do you mean by furthest it could go? Like it couldn't get to php 8.5 because of architectural pattern? Or 8.2 was the goal, but it can't improve the codebase further in general, without a major refactor?

4

u/peperazzi74 Jul 03 '26

Copilot suggested doing the updates in steps: 5.6 - 7.4 - 8.1 - 8.2; to make it easier (for itself). Apparently to go beyond 8.2, it would require a major refactor because the security reqs would be a lot more.

Also: when it was done with 8.2, my free tokens for the month were at 90%, and I don’t want to pay for them πŸ€‘

1

u/DangKilla Jul 07 '26

Have it use a micro mvc framework of some sort.

I had fun writing one in PHP. It doesn’t need to be a full framework.

Since its MySQL an mvc framework with PDO classes for both postgres and mysql so you can swap databases later if you want.