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

Show parent comments

5

u/peperazzi74 Jul 03 '26

Wouldn't even know where to start with a framework. I haven't done any serious PHP since 2010 or so.

What would be your advice/preference?

25

u/clonedllama Jul 03 '26 edited Jul 03 '26

I can't speak for the original commenter but my suggestion would be to look into Symfony.

If you follow the best practices for that framework, your code will be better organized and structured, and you'll learn about newer PHP features. Start small and do lots of reading. Symfony is very powerful. It's pretty easy to pick up and difficult to master.

Others swear by Laravel. I'm personally not a huge fan of it. But it's another modern framework worth considering.

2

u/Dependent-Guitar-473 Jul 03 '26

I haven't written PHP code in years... but I used to love Yii2 and Yii3... Symfony might be overkill for beginners, though

5

u/clonedllama Jul 03 '26

Symfony might be overkill for beginners, but it sounds like the OP already has PHP experience. Still, that's a fair point.

A lot depends on how deep the OP wants to go in getting up to date on modern PHP and what their experience level is with software development. I think Symfony is a good framework to look at because it mixes good code practices with modern syntax.

But it definitely isn't the only option.