> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP 8.6 is here!

> PHP 8.6 brings partial function application, a Time\Duration class, clamp() and safer session defaults. Here is how to upgrade on Upsun Cloud right away.


Fewer throwaway closures, durations you can add and compare instead of counting microseconds, and session cookies that are locked down by default. PHP 8.6 is a release of small, practical changes that show up in everyday code.

PHP 8.6 was [officially released](https://www.php.net/archive/2026.php#2026-11-19-5) on November 19, 2026, and you can use it on your Upsun Cloud projects today.

## How to upgrade

### Install it locally

Follow the official instructions for your system:

* [Unix systems](https://www.php.net/manual/install.unix.php)
* [macOS](https://www.php.net/manual/install.macosx.php)
* [Windows](https://windows.php.net/download/)

Then check the version:

```bash {filename="Terminal"} theme={null}
php -r 'echo PHP_VERSION;'
```

### Create a test environment

```bash {filename="Terminal"} theme={null}
upsun branch php-86-testing
```

### Update your dependencies

```bash {filename="Terminal"} theme={null}
composer update
```

### Switch the runtime version

Update the `type` of your app in `.upsun/config.yaml`:

```yaml {filename=".upsun/config.yaml"} theme={null}
applications:
  myapp:
    type: "php:8.6"
```

Push with `upsun push` and test the environment. When everything works, merge with `upsun merge`.

See the [supported PHP versions](https://developer.upsun.com/docs/languages/php#supported-versions) and the [available extensions](https://developer.upsun.com/docs/languages/php/extensions.md) in the Upsun Cloud docs.

> [!NOTE]
>
> **Before you upgrade production:** PHP 8.6 has [backward incompatible changes](https://www.php.net/manual/en/migration86.incompatible.php), 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](https://www.php.net/releases/8.6/en.php), with side-by-side comparisons
* [Migrating from PHP 8.5.x to PHP 8.6.x](https://www.php.net/manual/en/migration86.php), split into:
  * [New features](https://www.php.net/manual/en/migration86.new-features.php)
  * [New classes and interfaces](https://www.php.net/manual/en/migration86.new-classes.php)
  * [New functions](https://www.php.net/manual/en/migration86.new-functions.php)
  * [New global constants](https://www.php.net/manual/en/migration86.constants.php)
  * [Backward incompatible changes](https://www.php.net/manual/en/migration86.incompatible.php)
  * [Deprecated features](https://www.php.net/manual/en/migration86.deprecated.php)
  * [Other changes](https://www.php.net/manual/en/migration86.other-changes.php)

Here are the changes you are most likely to use first. The examples come from the [PHP 8.6 release page](https://www.php.net/releases/8.6/en.php) and the [migration guide](https://www.php.net/manual/en/migration86.new-features.php).

### 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:

```php theme={null}
$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];

$supportsPfa = array_filter(
    $versions,
    fn ($version) => version_compare($version, '8.6', '>='),
);
```

With PHP 8.6:

```php theme={null}
$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];

$supportsPfa = array_filter(
    $versions,
    version_compare(?, '8.6', '>='),
);
```

And with your own functions:

```php theme={null}
function add(int $a, int $b, int $c = 0): int
{
    return $a + $b + $c;
}

$addOne = add(1, ?);
var_dump($addOne(5)); // int(6)

$addToOne = add(1, ...);
var_dump($addToOne(2, 3)); // int(6)
```

### `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.

```php theme={null}
$timeout = \Time\Duration::fromSeconds(2)->add(\Time\Duration::fromMilliseconds(500));

printf("%d.%09d seconds\n", $timeout->seconds, $timeout->nanoseconds); // 2.500000000 seconds
var_dump($timeout > \Time\Duration::fromSeconds(2)); // bool(true)
```

### `clamp()`

Keep a value within bounds without nesting `min()` and `max()`:

```php theme={null}
var_dump(clamp(-10, 0, 100)); // int(0)
var_dump(clamp(50, 0, 100));  // int(50)
var_dump(clamp(110, 0, 100)); // int(100)
```

It works with any comparable value, `Duration` included.

### `SortDirection`

A shared enum with `Ascending` and `Descending` cases, so libraries can type sort order instead of accepting any integer:

```php theme={null}
public function orderBy(
    string $column,
    SortDirection $direction = SortDirection::Ascending,
): static {
    $this->orderBy[] = $column . ' ' . match ($direction) {
        SortDirection::Ascending => 'ASC',
        SortDirection::Descending => 'DESC',
    };

    return $this;
}
```

Passing `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:

```php theme={null}
class Config
{
    public readonly int $timeout = 30;
}
```

### And more

* **Polling API** (`Io\Poll`): scalable stream I/O multiplexing on epoll, kqueue, event ports or WSAPoll, past the limits of `stream_select()`. A new foundation for async libraries such as ReactPHP and AMPHP.
* **Structured stream errors**: opt in to `StreamException` with `StreamError` objects and a `StreamErrorCode` enum, instead of parsing `error_get_last()` messages.
* **URI builders**: `Uri\Rfc3986\UriBuilder` and `Uri\WhatWg\UrlBuilder` complete the URI extension added in PHP 8.5.
* **Reflection**: `ReflectionParameter::getDocComment()`, `ReflectionProperty::isReadable()` and `isWritable()`.
* **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](https://www.php.net/manual/en/migration86.incompatible.php) covers many extensions. These are the ones most likely to affect a web app:

* **Session defaults**: `session.use_strict_mode` is now `1`, `session.cookie_httponly` is now `1` and `session.cookie_samesite` is now `"Lax"`. Safer by default, but test cross-site flows such as embedded apps or single sign-on.
* **`trim()`, `ltrim()` and `rtrim()`** now strip form feed (`\f`) by default.
* **`ValueError` on bad input**: many functions, such as `getenv()`, `putenv()`, `filesize()` and `sleep()`, now throw for NUL bytes or out-of-range values.
* **`preg_grep()`** returns `false` on 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](https://www.php.net/manual/en/migration86.deprecated.php) is long. These are the most common in application code:

* `return` inside a `finally` block
* 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()` and `doubleval()`
* `spl_object_hash()`, in favor of `spl_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 the `type`, and see how your app runs on 8.6.

Found an extension or a framework that needs attention? Tell us on the [community forum](https://community.upsun.com/).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.