Modern Backend with PHP 8.2: What Changed and Why You Should Upgrade

Last month we connected to the server of a project we had just taken over: PHP 5.6. The year is 2023 and the version is 5.6 — an engine released eight years ago that hasn't received a single security patch in four and a half years, processing customer data in production. The interesting part is that the client had no idea; as far as they knew, "the system works." And it did work. A shop with its door left open works perfectly well too, until someone walks in.

Unfortunately, this scene is not the exception. PHP still runs roughly three quarters of the web, but a significant share of the installations out there are stuck on 5.6 or the 7.x series. Yet with 8.x, PHP became a completely different language. In this post I'll cover both the concrete benefits of 8.2 and how to upgrade without accidents — because both matter equally.

What in 8.2 actually helps us

There's no point listing the release notes; let me go through the items whose payoff we see in our daily work:

  • Readonly classes: With a single keyword, you make all of a class's properties immutable. Tailor-made for DTOs and value objects — the "who changed this object, and where?" hunt becomes a thing of the past.
  • Standalone null, true and false types: A method's return type can now be false or null on its own. API contracts get clearer; "returns false on failure" is now a guarantee of the type system.
  • #[\SensitiveParameter]: Parameters marked with this attribute are masked in stack traces. Speaking as someone who has seen cases where a customer's password ended up in a debug log: a small-looking but critical feature.
  • Performance: In projects we moved from 7.4 to 8.2, without any code optimization at all, we measured a 15-30 percent speedup under real-world load. Same hardware, same code, shorter response times.
Useful features of PHP 8.2: readonly classes, standalone null, true and false types, SensitiveParameter and a performance boost.
Same hardware, same code, shorter response times.

On top of these, there's the 8.0-8.1 legacy as a bonus: enums, constructor property promotion, the match expression — to someone looking from 5.6 or 7.2, 8.2 will seem like a distant relative of the same language. In a good way.

The flip side: 8.2 also officially retires some old habits. The most talked-about is dynamic properties — assigning a value to a property not declared in the class is now deprecated. Not a problem for modern code, but in legacy projects, especially code written in the "stick whatever field comes to mind onto the object" style, brace yourself for a flood of warnings. Don't let the word "warning" fool you; these are signals that will turn into errors in a future version, so they need to be cleaned up now as part of the upgrade plan.

The bill for staying on an old version arrives every month

I understand the "don't touch a working system" philosophy; we're against unnecessary changes too. But here, not touching it is the risk in itself.

First, security: security support for PHP 7.4 ended last November. Today, every system running on 7.4 or below will receive no patch for any vulnerability discovered from now on. When a vulnerability is discovered (and they are), your only option will be to jump versions in a hurry, without a plan, in the middle of a fire — in other words, the most expensive and riskiest way to upgrade.

Second, the ecosystem: modern libraries are quickly abandoning old PHP. Current versions of frameworks, payment providers' SDKs, API clients... As each of them raises its minimum version requirement, your project on the old version starts living cut off from updates. Technical debt grows, interest and all.

Third, the human side — nobody talks about it, but it's real: good developers don't want to work on legacy PHP. A project stuck on an old version also struggles to find a team.

Going back to the 5.6 project from the start of this post: we sat down with the client and put the cost of the two scenarios side by side. A planned upgrade — with its tests and a gradual transition — is a controlled effort of a few weeks. The alternative scenario, suffering a data breach one day because of a vulnerability: a KVKK (Turkey's personal data protection law) notification, a possible administrative fine, lost customers, reputation repair, and the very same upgrade, this time done in the middle of a fire. Once the client saw the table, they made the decision in five minutes. An upgrade looks expensive — until you write the price of not doing it in the next column.

A planned upgrade is a controlled effort of a few weeks; not upgrading means a data breach, fines, lost customers and an upgrade in the middle of a fire.
Once the client saw the two scenarios side by side, they decided in five minutes.

Four steps to an accident-free upgrade

Now for the hands-on part. Here's the sequence we've applied many times and have now standardized.

First, a test safety net: write smoke tests that cover the critical business flows (login, orders, payments, reports). A comprehensive test suite isn't required — it would be great to have, but it's not realistic on a legacy project; a set that quickly answers "is the system up, and is the money flowing?" is enough to start.

Next, static analysis: hook PHPStan into the project and see usages incompatible with the target version without running anything. Removed functions, changed signatures, type mismatches — you want to see that list as lines in an analysis report, not as errors in production. Tools like Rector can even perform part of the conversion automatically.

Add one more item to the static analysis stage: dependencies. Even if your own code is ready for 8.2, not every package in composer.json may be able to say the same. When you start the upgrade plan, dump the package list and mark which ones support 8.2 and which have been abandoned. If an abandoned package turns up (they do, and often), migrating to an alternative becomes part of the upgrade project's scope — knowing this at the start rather than discovering it halfway through is the only way to build a realistic schedule.

The third step is a gradual transition: instead of jumping straight from 5.x or 7.x to 8.2, clearing the deprecation warnings on 8.1 and then moving to 8.2 goes much more smoothly. At each step you know what broke; in one giant leap, debugging turns into looking for a needle in a haystack.

The fourth is hunting for behavior changes — the sneakiest part. For example, starting with 8.0, PDO's error mode throws exceptions by default; a query that used to silently return false now stops the application. The number one cause of post-upgrade "white screen" incidents is silent default changes like this. The "backward incompatible changes" section of the release notes is the real specification of an upgrade project; it has to be read, thoroughly.

The upgrade is done in four steps: a test safety net, static analysis, a gradual transition and hunting for behavior changes.
At each step, you know what broke.

I owe the operations side a paragraph too. We don't do upgrades as "update PHP on the server and hope for the best"; the new version is set up in a separate environment (a container or a separate FPM pool), a small percentage of traffic is routed there first, error rates and response times are monitored, and if no problems appear, the share is increased gradually. A way back stays open at all times. This setup may sound overly cautious; but writing the plan up front is always cheaper than frantically searching at midnight for "how did we roll back to the old version again?"

A short note for those who are waiting

Some will say, "8.3 is coming at the end of the year anyway, let's wait for that." Don't wait. The version race has no finish line; while you wait for 8.3, 8.4 will be announced. What matters is getting into the current, supported range; the small jumps after that are child's play compared to the first big one.

If you have a legacy project that's been limping along for years and you're wondering "where do we even start," get in touch — first we'll map out the current state and lay it in front of you along with its risks, and then we'll draw the upgrade roadmap together. We're moving that 5.6 project right now with this same method, on a plan under which the client hasn't had a single day of downtime. It can be done; it just mustn't be done without a plan.