PHP 8.2 Dies on December 31, 2026: PHP 8.4 vs 8.5 vs 8.6 — Which One Do You Migrate To?

PHP 8.2 stops receiving security fixes on December 31, 2026. That is roughly five weeks from today, and it is not the only deadline in the room: PHP 8.4 also drops out of active support on the exact same date, moving to security-only until the end of 2028. Meanwhile PHP 8.6 shipped on November 19, 2026, only ten days ago.

So the question is not “should I upgrade” — it is “which of three supported versions do I target”, and the wrong answer locks you into a version that is already half-dead on arrival. Here is the decision framework, the verified support dates, and the syntax changes that actually break code.

TL;DR — the verdict

  • Almost everyone should target PHP 8.5. It shipped in November 2025, has a full year of production mileage, active support until December 31, 2027, and security fixes until December 31, 2029. It is the only version that is both mature and fully supported right now.
  • Use PHP 8.4 only as a stopgap if a critical dependency has not shipped 8.5 support. It is security-only after December 31, 2026 — no bug fixes, no performance work.
  • Use PHP 8.6 for greenfield projects where you control every dependency and can tolerate ecosystem lag. It is supported until 2030, but it is ten days old.
  • Never stay on PHP 8.2. Zero security releases after December 31, 2026.

Verified support timeline

VersionReleasedActive support endsSecurity support endsHeadline additions
PHP 8.22022-12-082024-12-312026-12-31Readonly classes, DNF types, Randomizer
PHP 8.32023-11-232025-12-312027-12-31Typed class constants, json_validate(), #[\Override]
PHP 8.42024-11-212026-12-312028-12-31Property hooks, asymmetric visibility, #[\Deprecated]
PHP 8.52025-11-202027-12-312029-12-31Pipe operator, #[\NoDiscard], closures in constant expressions
PHP 8.62026-11-192028-12-312030-12-31Partial function application, #[\Override] on class constants

The table makes the trap obvious. Migrating from 8.2 to 8.4 today buys you twelve months of security support and then a second migration in 2028. Migrating to 8.5 buys you three years and costs the same engineering effort. The only reason to pick 8.4 is a hard dependency blocker.

Decision matrix

Your situationTargetWhy
Typical production app on a mainstream frameworkPHP 8.5Mature, active support to Dec 2027, three years of security
Legacy app with abandoned Composer packagesPHP 8.4Widest compatibility; treat as a 12-month bridge
New project starting this quarterPHP 8.6Longest support window, newest syntax
WordPress, Drupal, or a CMS with plugin ecosystemsPHP 8.5Plugin authors target the previous stable major
High-traffic app needing bytecode stabilityPHP 8.5One year of OPcache and JIT fixes behind it
Shared hosting you do not controlCheck the panel firstThe host’s available versions decide, not you
Still on PHP 8.2 in December 2026PHP 8.5, this monthFive weeks of runway and a 3-version jump

PHP 8.4 — property hooks and the last “big syntax” release you may not have used yet

PHP 8.4’s headline feature is property hooks: properties can define get and set behavior without a backing method pair.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?php
// PHP 8.4+ — property hooks replace getter/setter boilerplate
class Money
{
    public string $formatted {
        get => number_format($this->amount / 100, 2) . ' ' . $this->currency;
    }

    public function __construct(
        public readonly int $amount,
        public readonly string $currency = 'EUR',
    ) {}
}

$price = new Money(1999, 'EUR');
echo $price->formatted; // "19.99 EUR"

Asymmetric visibility lands alongside it: public private(set) string $id means the property is readable everywhere but writable only inside the class — the read-only property you always wanted without a constructor dance. And #[\Deprecated] lets you mark functions, methods, and class constants as deprecated so tooling can surface usage before removal.

The migration relevance is not the features themselves. It is that if you jump from 8.2 to 8.5, you inherit 8.4’s deprecations too. The most common one in real codebases is implicit nullable parameters: function f(string $x = null) is deprecated in favor of function f(?string $x = null). It still runs in 8.x, but the warning noise hides real problems, and both phpstan and psalm will flag it at higher levels.

PHP 8.5 — the version that actually removes boilerplate

PHP 8.5 is the target I recommend, and its features are the kind that change how code reads rather than how it compiles.

The pipe operator

1
2
3
4
5
6
7
<?php
// PHP 8.5 — left-to-right data flow
$slug = $title
    |> trim(...)
    |> strtolower(...)
    |> (fn (string $s): string => preg_replace('/[^a-z0-9]+/', '-', $s))
    |> trim(..., '-');

Each stage receives the previous result as its argument. For anyone who has written deeply nested preg_replace(strtolower(trim($x))) chains — or a collect() pipeline in a framework just to keep it readable — this is a real quality-of-life improvement, and it is native.

#[\NoDiscard] and the (void) cast

1
2
3
4
5
6
<?php
#[\NoDiscard("Check the result: a failed write returns false")]
function atomic_write(string $path, string $data): bool { /* ... */ }

atomic_write('/var/app/config.json', $json);   // warning: result unused
(void) atomic_write('/var/app/cache.json', $json); // explicit "I know"

This is the PHP equivalent of Go’s unused-return discipline, and it is opt-in per function. If you maintain a library, adding #[\NoDiscard] to functions whose return value matters is a cheap correctness win — and one of the few upgrades that improves callers’ code.

Closures in constant expressions

Closures and first-class callables are now allowed in constant expressions, including attribute arguments, property defaults, and class constants. It is a niche feature until you need it — and when you build attribute-driven validation or DI configuration, you will.

PHP 8.6 — newest syntax, youngest ecosystem

PHP 8.6 landed on November 19, 2026 with partial function application as its marquee feature: a call where one or more arguments are replaced by ? (or the remaining arguments by ...) evaluates to a Closure.

1
2
3
4
5
6
<?php
// PHP 8.6 — partial application creates a closure from a call
$containsPhp = str_contains(?, 'php');
var_dump($containsPhp('php 8.6')); // bool(true)

$fetchUser = $repository->findById(...); // closure over remaining args

It also extends #[\Override] to class constants, so a constant that claims to override a parent constant fails loudly when no match exists — a genuinely useful guard for interface-driven code.

Adopting 8.6 in November 2026 is a bet on ecosystem speed. Frameworks ship support within weeks, but the long tail — payment SDKs, CMS plugins, image libraries, anything with a binary extension — lags months behind. If a dependency ships prebuilt binaries only for versions up to 8.5, you will be compiling from source or waiting.

The migration path that does not break production

Step 1: pin the target in Composer, not just in the interpreter

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "require": {
    "php": ">=8.5 <8.7"
  },
  "config": {
    "platform": {
      "php": "8.5.13"
    }
  }
}

The platform key matters more than it looks: it makes Composer resolve dependencies as if it were running the pinned version, so a laptop on 8.4 and CI on 8.5 produce identical lockfiles. Teams that skip this get “works on my machine” lockfile drift, which then fails inside the container.

Step 2: let tooling find the deprecations for you

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Syntax check every file under the new interpreter
find . -name '*.php' -not -path './vendor/*' -print0 | xargs -0 -n1 -P8 php -l

# Automated upgrade rules (property hooks, implicit nullable, etc.)
composer require --dev rector/rector
vendor/bin/rector process src --dry-run

# Static analysis at a level you actually enforce
composer require --dev phpstan/phpstan
vendor/bin/phpstan analyse src --level=6

Running rector --dry-run against a 8.2 codebase typically produces a list you can apply in batches. Do not apply everything at once: split mechanical fixes (nullable annotations, deprecated calls) from behavioural ones (property hooks replacing getters) into separate commits so a rollback is possible.

Step 3: test on the real matrix in CI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# .github/workflows/ci.yml
name: ci
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-24.04
    strategy:
      fail-fast: false
      matrix:
        php: ["8.4", "8.5"]
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: mbstring, intl, pdo_mysql, opcache
          coverage: none
      - run: composer install --no-interaction --prefer-dist
      - run: vendor/bin/phpunit

Keeping 8.4 in the matrix during the transition tells you immediately whether a package you just added assumes a newer runtime, and it gives you a fallback target if 8.5 breaks something in production.

Step 4: update the runtime image and OPcache config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
FROM php:8.5-fpm-bookworm

RUN docker-php-ext-install pdo_mysql opcache intl \
 && pecl install apcu \
 && docker-php-ext-enable apcu

COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
USER www-data
1
2
3
4
5
6
7
8
; opcache.ini — conservative, production-safe baseline
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
opcache.jit=tracing
opcache.jit_buffer_size=128M

validate_timestamps=0 means OPcache never re-reads files — correct for immutable containers, catastrophic on a bind-mounted dev directory. If your deploy relies on in-place file updates rather than new containers, leave it at 1 or you will deploy code that never runs.

Traps that bite during a PHP 8.2 to 8.5 jump

Trap 1: the implicit nullable deprecation is everywhere. function f(string $x = null) has been deprecated since 8.4. Large codebases often have hundreds. Fix them in one mechanical commit before touching anything else, otherwise your logs are useless for spotting real issues.

Trap 2: dynamic properties. Creating undeclared properties on a class is deprecated since 8.2 — if you are coming from 8.1 or earlier, code that “worked” now emits warnings. Add #[\AllowDynamicProperties] only as a temporary measure, and prefer explicit properties or stdClass for data bags.

Trap 3: OPcache preloading breaks silently. If your preload script lists files that were renamed or removed during the upgrade, PHP-FPM fails to start with a cryptic message. Test opcache.preload in staging with the exact production file list — and remember that preloading changes do not apply without a full FPM restart.

Trap 4: binary extensions lag the interpreter. imagick, rdkafka, swoole, and anything installed via PECL must be rebuilt per PHP minor version. Check that each extension publishes support for your target major before the cutover, not during it.

Trap 5: Composer plugins that assume the platform. Deployment plugins and patches plugins frequently hard-code version checks. Run composer diagnose and a full composer install --no-dev in a clean container to catch these — the failure mode is a production deploy that dies at the install step.

Trap 6: framework minimums cut both ways. Laravel 11+ requires PHP 8.2 minimum, so 8.2’s death does not force a framework upgrade. But some framework versions also cap the supported PHP minor at release time; check your framework’s support matrix rather than assuming “newer PHP is always fine”.

Migration checklist

  • Pin php and config.platform.php in composer.json
  • Run php -l across the codebase under the target interpreter
  • Apply Rector rules in separate, revertible commits
  • Fix implicit-nullable and dynamic-property deprecations first
  • Add the target version to the CI matrix alongside the current one
  • Rebuild every PECL extension for the new minor version
  • Verify opcache.preload against the deployed file list
  • Run a full composer install --no-dev in a clean container
  • Soak in staging for a week with production traffic levels
  • Remove the old version from the matrix after two green weeks

If you are moving to 8.6 specifically, our PHP 8.6 upgrade guide walks through the partial function application syntax and the deprecations in detail. For runtime tuning once you are on 8.5 or later, the OPcache, JIT and php-fpm pool tuning guide covers the settings that actually move latency. And if you are running PHP behind a long-lived application server, the Swoole vs RoadRunner vs FrankenPHP comparison explains why the interpreter upgrade alone may not be your bottleneck.

FAQ

When exactly does PHP 8.2 reach end of life? December 31, 2026. After that date the PHP project publishes no security fixes for the 8.2 branch, and any vulnerability disclosed in the runtime or its bundled extensions remains unpatched.

Which PHP version should I migrate to from 8.2? PHP 8.5 for almost all production systems: it has a year of production mileage, active support until December 2027, and security support until December 2029. PHP 8.4 is a stopgap only, and PHP 8.6 is for greenfield projects.

Is PHP 8.4 still supported in 2027? Yes, but only for security fixes. Active support ends December 31, 2026, which means no bug fixes or performance improvements after that date — it remains patched against vulnerabilities until December 31, 2028.

Will my Composer dependencies break on PHP 8.5? Most mainstream packages already declare 8.5 support. The risky categories are binary extensions, abandoned packages with hard-coded version checks, and CMS plugins. Run composer install --no-dev in a clean container on the target version to find out before you deploy.

How long does a PHP 8.2 to 8.5 migration take? For a mid-sized application, three to five days of engineering plus a staging soak. Deprecation cleanup and PECL extension rebuilds dominate the effort; the interpreter swap itself is a Dockerfile change.

Does PHP 8.6 support all the syntax from 8.4 and 8.5? Yes. PHP releases are additive within a major version, so 8.4’s property hooks, 8.5’s pipe operator, and 8.6’s partial function application are all available on the newest branch. Upgrading to 8.6 does not cost you earlier features.


💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com