How to upgrade
Install it locally
Follow the official instructions for your system: Then check the version:Create a test environment
Update your dependencies
Switch the runtime version
Update thetype of your app in .upsun/config.yaml:
upsun push and test the environment. When everything works, merge with upsun merge.
See the supported PHP versions and the available extensions in the Upsun Cloud docs.
Before you upgrade production: PHP 8.6 has backward incompatible changes, including new session defaults. Review them, and the checklist at the end of this post, on your test environment first.
What’s new in PHP 8.6
The PHP team publishes everything you need to plan the upgrade:- The release page, with side-by-side comparisons
- Migrating from PHP 8.5.x to PHP 8.6.x, split into:
Partial function application
Fix some of a function’s arguments in advance and get a closure that takes the rest.? stands for one argument, ... for all the remaining ones. It works with any callable, including internal functions.
Previously, filtering a list with a built-in function meant writing an arrow function:
Time\Duration
Timeouts, delays and retry backoffs no longer have to be integers in an implicit unit. Time\Duration is an immutable value with nanosecond precision, independent of time zones. You can add, subtract, multiply and compare durations directly.
clamp()
Keep a value within bounds without nesting min() and max():
Duration included.
SortDirection
A shared enum with Ascending and Descending cases, so libraries can type sort order instead of accepting any integer:
SORT_STRING by mistake now fails with a TypeError at the call, instead of an UnhandledMatchError deep inside the method.
Readonly property defaults
Readonly properties and readonly classes can declare a default value, so you no longer need a constructor just to set a constant:And more
- Polling API (
Io\Poll): scalable stream I/O multiplexing on epoll, kqueue, event ports or WSAPoll, past the limits ofstream_select(). A new foundation for async libraries such as ReactPHP and AMPHP. - Structured stream errors: opt in to
StreamExceptionwithStreamErrorobjects and aStreamErrorCodeenum, instead of parsingerror_get_last()messages. - URI builders:
Uri\Rfc3986\UriBuilderandUri\WhatWg\UrlBuildercomplete the URI extension added in PHP 8.5. - Reflection:
ReflectionParameter::getDocComment(),ReflectionProperty::isReadable()andisWritable(). - Security: TLS session resumption, and post-quantum key encapsulation in Sodium (X-Wing, ML-KEM-768).
What to check before upgrading
Breaking changes
The full list covers many extensions. These are the ones most likely to affect a web app:- Session defaults:
session.use_strict_modeis now1,session.cookie_httponlyis now1andsession.cookie_samesiteis now"Lax". Safer by default, but test cross-site flows such as embedded apps or single sign-on. trim(),ltrim()andrtrim()now strip form feed (\f) by default.ValueErroron bad input: many functions, such asgetenv(),putenv(),filesize()andsleep(), now throw for NUL bytes or out-of-range values.preg_grep()returnsfalseon a PCRE execution error, instead of a partial array.unpack()reads<and>after a format code as an endianness modifier, which changes the keys of some existing format strings.
Deprecations
Run your test suite with deprecations visible. The full list is long. These are the most common in application code:returninside afinallyblock- Returning a value from
__construct()or__destruct() - The mbstring regex functions (
mb_ereg*,mb_split()and related), planned for removal in PHP 9.0 is_double(),is_long(),is_integer()anddoubleval()spl_object_hash(), in favor ofspl_object_id()define()with a third argument
What’s next
PHP 8.6, 8.5, and 8.4 are the supported PHP versions on Upsun Cloud. Create a branch, switch thetype, and see how your app runs on 8.6.
Found an extension or a framework that needs attention? Tell us on the community forum.