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
| Version | Released | Active support ends | Security support ends | Headline additions |
|---|---|---|---|---|
| PHP 8.2 | 2022-12-08 | 2024-12-31 | 2026-12-31 | Readonly classes, DNF types, Randomizer |
| PHP 8.3 | 2023-11-23 | 2025-12-31 | 2027-12-31 | Typed class constants, json_validate(), #[\Override] |
| PHP 8.4 | 2024-11-21 | 2026-12-31 | 2028-12-31 | Property hooks, asymmetric visibility, #[\Deprecated] |
| PHP 8.5 | 2025-11-20 | 2027-12-31 | 2029-12-31 | Pipe operator, #[\NoDiscard], closures in constant expressions |
| PHP 8.6 | 2026-11-19 | 2028-12-31 | 2030-12-31 | Partial 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 situation | Target | Why |
|---|---|---|
| Typical production app on a mainstream framework | PHP 8.5 | Mature, active support to Dec 2027, three years of security |
| Legacy app with abandoned Composer packages | PHP 8.4 | Widest compatibility; treat as a 12-month bridge |
| New project starting this quarter | PHP 8.6 | Longest support window, newest syntax |
| WordPress, Drupal, or a CMS with plugin ecosystems | PHP 8.5 | Plugin authors target the previous stable major |
| High-traffic app needing bytecode stability | PHP 8.5 | One year of OPcache and JIT fixes behind it |
| Shared hosting you do not control | Check the panel first | The host’s available versions decide, not you |
| Still on PHP 8.2 in December 2026 | PHP 8.5, this month | Five 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.
| |
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
| |
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
| |
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.
| |
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
| |
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
| |
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
| |
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
| |
| |
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
phpandconfig.platform.phpincomposer.json - Run
php -lacross 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.preloadagainst the deployed file list - Run a full
composer install --no-devin 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