Skip to content

Web Development · Backend

PHP 8.2 End of Life: Upgrade to PHP 8.5, Not 8.6

PHP 8.2 loses security support on December 31, 2026. Move to PHP 8.5, supported until 2029. What breaks between 8.2 and 8.5, and how to find it early.

Abhishek Gupta

Abhishek Gupta

12 min read

A small blue-grey elephant carrying wooden crates beside a ramp up to a bright stone terrace with a potted tree, above cracked grey stone

Sponsored

Share

PHP 8.2 has six weeks left. It reaches end of life on December 31, 2026, when its security support ends, and after that the PHP project ships no more 8.2 releases. If an app of yours still runs on it, upgrade to PHP 8.5. Not 8.4, and not PHP 8.6, which reaches general availability tomorrow.

The dates below come from php.net’s supported versions page, and the list of breaking changes comes from the official migration guides for 8.3, 8.4 and 8.5, linked at the end.

PHP 8.2 end of life: what actually changes on January 1

Nothing breaks on New Year’s Day. Your 8.2 binaries keep serving requests exactly as they did in December. What ends is the supply of fixes. A bug in the engine, in ext/curl or in the bundled PCRE that gets reported in February is fixed in 8.3, 8.4 and 8.5, and 8.2 keeps it.

One nuance matters for servers: if you install PHP from an LTS Linux distribution’s own packages rather than from php.net builds or the official Docker images, the distro may keep backporting security fixes for longer. That’s your distro’s promise, not PHP’s, so check it rather than assume it.

The ecosystem pressure arrives faster than the security risk. Laravel 13 already requires PHP 8.3, and WordPress 7.1’s compatibility table lists 8.3, 8.4 and 8.5 as its tested versions. Packages raise their require.php floor a few months after a branch dies, so an 8.2 app slowly gets stuck on old versions of everything it installs.

Upgrade PHP 8.2 to 8.5, 8.4 or 8.6?

Upgrade to PHP 8.5. It’s the only branch still in active support through all of 2027, which means ordinary bugs get fixed there, not only security holes, and its security support runs to December 31, 2029. It also has a year of patch releases behind it and sits inside the supported range of every major framework.

VersionReleasedActive support untilSecurity support untilVerdict
8.2Dec 8, 2022Dec 31, 2024 (ended)Dec 31, 2026Leave it
8.3Nov 23, 2023Dec 31, 2025 (ended)Dec 31, 2027You’d do this again next year
8.4Nov 21, 2024Dec 31, 2026Dec 31, 2028Fallback if 8.5 is blocked
8.5Nov 20, 2025Dec 31, 2027Dec 31, 2029Default target
8.6Nov 19, 2026 (scheduled)not yet publishednot yet publishedTest it in CI, don’t ship it yet

Bar chart of PHP 8.2 to 8.5 support windows: 8.2 ends December 31, 2026, 8.3 is security-only until the end of 2027, 8.4 leaves active support at the end of 2026, and 8.5 has active support through 2027 and security fixes until the end of 2029

The 8.4 row is the trap. It looks current, and today it is. But its active support ends on December 31, the same day 8.2’s security support does, so on January 1 you’d be on a security-only branch again. You’d also have done most of the work 8.5 needs anyway, since the biggest deprecation wave (implicitly nullable parameters) arrives in 8.4.

Why not 8.6? The PHP 8.6 release schedule puts GA on November 19, 2026. Three reasons to wait a few months:

  1. Framework support lags. Laravel’s support table lists PHP 8.3 to 8.5 for Laravel 13, and WordPress’s table stops at 8.5. Neither has certified 8.6 yet.
  2. Compiled extensions are built per minor version. Every PECL extension you load (Redis, Imagick, Xdebug, APCu, whatever your Dockerfile installs) has to publish a build that works against 8.6 before your image builds cleanly.
  3. A .0 release always gets the first round of regressions. Let 8.6.2 or 8.6.3 absorb them.

Run 8.6 as a non-blocking CI job so you see what it flags. Ship 8.5.

Check your framework first

The framework decides how much room you have.

You runSupported PHPWhat to do
Laravel 118.2 to 8.4Upgrade to Laravel 12 first. Laravel 11’s security fixes ended March 12, 2026.
Laravel 128.2 to 8.5Change PHP to 8.5 now, Laravel later
Laravel 138.3 to 8.5You’re already off 8.2; confirm production agrees
WordPress 7.18.3 to 8.5 testedUpgrade PHP, then test every plugin

On Laravel 12, change PHP and the framework in separate deploys. The Laravel 12 to 13 upgrade guide recommends the same order for the same reason: when something breaks, you want one suspect, not two. If you’re weighing whether Laravel is still the right base for the app at all, the Laravel in 2026 overview covers where the framework stands now.

How to upgrade from PHP 8.2 to 8.5, step by step

  1. Find every place 8.2 is pinned.
  2. Ask Composer which dependencies block 8.5.
  3. Add 8.5 to CI next to 8.2, with every deprecation reported.
  4. Let Rector fix the mechanical changes, and PHPStan find the rest.
  5. Work through the breaking changes below, then flip the default.

Step 1 is wider than composer.json. The version also hides in Dockerfiles, CI matrices, apt package names and hosting panels:

# Every place PHP 8.2 is pinned, outside vendor and node_modules
grep -rnE "php:?8\.2|php8\.2|php-version:? *['\"]?8\.2|\"php\": *\"[^\"]*8\.2" \
  --include=Dockerfile* --include=*.json --include=*.yml --include=*.yaml \
  --include=*.ini --include=*.conf --include=*.sh \
  --exclude-dir=vendor --exclude-dir=node_modules .

Managed hosts (Forge, Ploi, cPanel, a PaaS) keep the PHP version in their own settings, not in your repo, so check those by hand.

For step 2, Composer answers the question directly:

composer why-not php 8.5

Every package it lists needs a newer version, a replacement, or a fork. Abandoned packages surface here first. To resolve dependencies for 8.5 before you install it locally, set the platform version temporarily:

{
  "require": {
    "php": "^8.5"
  },
  "config": {
    "platform": {
      "php": "8.5.0"
    }
  }
}

Then composer update and read the diff of composer.lock. Remove the platform override once production runs 8.5, otherwise Composer will keep pretending.

For step 3, run the suite on both versions and make deprecations visible. A GitHub Actions matrix with shivammathur/setup-php does it:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php: ["8.2", "8.5"]
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          ini-values: error_reporting=E_ALL, display_errors=On
      - run: composer install --no-interaction --prefer-dist
      - run: vendor/bin/phpunit --display-deprecations

Add an 8.6 entry with continue-on-error: true once 8.6 lands in setup-php.

Rector and PHPStan do most of the typing

Two tools take this from a week to a day. Rector reads your composer.json PHP constraint and applies the upgrade rules up to that version, so after you raise require.php to ^8.5, this config targets 8.5:

<?php
// rector.php
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([__DIR__ . '/app', __DIR__ . '/src', __DIR__ . '/tests'])
    ->withPhpSets();

Run vendor/bin/rector --dry-run first and read the diff before you let it write. Rector rewrites implicitly nullable parameters, old casts and similar mechanical changes far more reliably than a find-and-replace.

PHPStan catches what Rector doesn’t rewrite: calls to functions whose signatures changed, and code that only type-checks on the old version. Tell it which PHP to analyse against with the phpVersion setting. Since PHPStan 2.0 it accepts a range, which is what you want while both versions are live:

# phpstan.neon
parameters:
    phpVersion:
        min: 80200
        max: 80500

What breaks between PHP 8.2 and 8.5

Three releases of changes land at once. Here they are, sorted by how often they hurt a typical web app, not by version.

Implicitly nullable parameters (deprecated in 8.4)

This is the one that fills your logs. A typed parameter with a null default used to become nullable silently. PHP 8.4 deprecates that:

// Deprecated in PHP 8.4: the type says User, the default says null
function notify(User $user = null) {}

// Fix: say what you mean
function notify(?User $user = null) {}

It’s a deprecation, so the code still runs. But a busy app can write thousands of these notices per minute, and older packages are full of the pattern. Rector fixes your code; composer update fixes most packages.

PDO driver constants and resource close calls (deprecated in 8.5)

PHP 8.4 added driver-specific PDO subclasses, and 8.5 deprecates the old driver constants on the base PDO class. Laravel apps created on older skeletons carry one in config/database.php, for the MySQL SSL option:

// Deprecated in PHP 8.5
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),

// Replacement (the class exists from PHP 8.4)
Pdo\Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),

If the same code must still boot on 8.2 during the rollout, keep the old constant until 8.2 is gone from every environment, then switch.

PHP 8.5 also deprecates the close functions for things that are now objects and get freed automatically: curl_close(), curl_share_close(), finfo_close(), imagedestroy() and xml_parser_free(). Delete the calls. Rounding out the 8.5 list are the backtick shell operator (use shell_exec()), the long casts (integer), (boolean), (double) and (binary), null as an array offset, and case labels ending in a semicolon.

Four extensions left the core (8.4)

PHP 8.4 moved IMAP, OCI8, PDO_OCI and PSpell to PECL. If your app reads a mailbox with imap_open() or talks to Oracle, docker-php-ext-install imap stops working and you need the PECL package instead. For IMAP, a pure-PHP client library from Packagist is usually less painful than compiling the extension yourself. Find out early:

php -m | grep -iE "imap|oci8|pdo_oci|pspell"
grep -rnE "imap_(open|search|fetch)|oci_connect|pspell_" --include=*.php \
  --exclude-dir=vendor .

Stricter argument checks (8.3 to 8.5)

Across all three releases, functions that used to accept bad input and guess now throw ValueError or TypeError. The ones that turn up in real code:

ReleaseChangeWhat you’ll see
8.3range() validates its arguments, and range('9', 'A') now returns charactersTypeError, or a different array
8.3number_format() with negative decimals now rounds left of the pointDifferent output where you passed a negative value
8.3Date extension throws DateMalformedStringException and friendsDateTime::modify() throws where it warned and returned false
8.4round() with an invalid modeValueError instead of silent half-up
8.4str_getcsv() with a multi-byte separator or enclosureValueError
8.4exit() and die() follow normal type rulesTypeError on odd arguments
8.5Casting a float that doesn’t fit to intNew warning
8.5Destructuring a non-array (other than null) with [] or list()New warning
8.5SimpleXMLElement::xpath() on a non-node-set expressionReturns false, not []

The Date change is the one to grep for. Code that calls $date->modify($userInput) and then checks the result for false never gets false on 8.3. It gets an exception, and if nothing catches it, the request returns a 500. Search for ->modify( and wrap the calls that take outside input.

Smaller items worth a minute each

  • E_STRICT is gone and its constant is deprecated (8.4). Remove it from error_reporting() calls.
  • trigger_error() with E_USER_ERROR is deprecated (8.4). Throw an exception instead.
  • Changing session.sid_length or session.sid_bits_per_character is deprecated (8.4). Drop the ini overrides and let PHP use its defaults.
  • Opcache is always built in on 8.5. A zend_extension=opcache.so line in your ini files now emits a warning, so remove it.
  • The disable_classes ini setting was removed in 8.5. If your hardening config relied on it, find another control.
  • $http_response_header is deprecated in 8.5. Use http_get_last_response_headers().

The bcrypt cost change nobody notices until login gets slow

PHP 8.4 raised the default cost for password_hash() with PASSWORD_DEFAULT and PASSWORD_BCRYPT from 10 to 12, which PHP.Watch documents along with the reasoning. Each step doubles the work, so a cost-12 hash takes about four times as long to compute as a cost-10 one.

Two effects follow. If your login code calls password_needs_rehash($hash, PASSWORD_DEFAULT), it now returns true for every old hash, so each user’s next login rehashes their password. That’s the intended outcome, but it’s extra CPU on the first busy day after the deploy. And every login and registration from then on costs more, which matters on small containers with tight CPU limits. If you set cost explicitly (Laravel and Symfony both pass their own configured value), nothing changes until you change it.

Roll it out one environment at a time

Build an 8.5 image, deploy it to staging, and run your slowest jobs there: queue workers, scheduled imports, PDF generation, anything that touches an extension. Sort the deprecation log by volume, not by distinct message, and fix the noisiest first, because one implicitly nullable parameter in a hot path can outweigh fifty rare ones. Then put production on 8.5 with the old image ready to roll back to.

Other end-of-life deadlines this autumn follow the same logic. The Python 3.10 end-of-life guide and the PostgreSQL 14 end-of-life guide both pick the mature supported release over the newest one, for the same reasons 8.5 beats 8.6 today. If the upgrade is landing on an app nobody on the current team wrote, the checklist for inheriting a codebase from another agency is worth running first, because an unknown composer.lock is where most of the surprises in this guide come from.

The order is short: composer why-not php 8.5 today, the CI matrix this week, Rector and the extension check next, then staging. Teams that start in December are doing it over the holidays, against a hard date.

Frequently asked questions

Will my PHP 8.2 site stop working on January 1, 2027?
No. The interpreter keeps running the same code. What stops is maintenance: the PHP project publishes no more 8.2 releases, so security bugs found in 2027 get fixed in 8.3 and newer only. Linux distributions with long-term support may backport fixes to their own 8.2 packages, but that depends on your distro, not on php.net.
Can I go straight from PHP 8.2 to 8.5?
Yes. There's no need to stop on 8.3 or 8.4. You do need to read the backward-incompatible changes for all three releases, because every one of them applies to you in a single hop.
Do I need to upgrade Laravel before upgrading PHP?
It depends on your version. Laravel 12 and 13 both support PHP 8.5. Laravel 11 supports PHP 8.2 to 8.4 and stopped receiving security fixes on March 12, 2026, so a Laravel 11 app should move to Laravel 12 first, then change PHP.

Sources

Sponsored

Sponsored

Discussion

Join the conversation.

Comments are powered by GitHub Discussions. Sign in with your GitHub account to leave a comment.

Sponsored