Back to Blog
PHP 8.6 Is Out, and Here Is What I Would Look At First as a Laravel Developer
PHP 8.6.0 was released on November 19, 2026. A practical read of what is new, what is deprecated, and what Laravel and PHP developers should check before upgrading.
Back
Backend
Table of contents
PHP 8.6.0 was released today, November 19, 2026. The release page on php.net says it is a major update, with Partial Function Application, a new Duration class, a Polling API, and a clamp() function as the headline items.
I went through the release announcement, the RFC pages, and the UPGRADING file in the PHP-8.6 branch of php-src. This is not a full changelog. It is the part I would read before touching a production Laravel app.
One note on the code below. The examples come from the RFCs and the official release page, and I ran them on PHP 8.6.0 built from the official source tarball. Where the output differed from what I expected, I changed the text. Three areas were not tested because that build had no support for them: the mbstring regex functions, Sodium, and mysqli. Treat those parts as read from the release notes only.
Release status
PHP 8.6.0 is a stable release, not a beta or a release candidate. The official timetable on the wiki shows a feature freeze in August and September, a run of release candidates from RC2 in late September to RC7 on November 12, and general availability on November 19. There was no RC1 on the schedule in the end. The php.net announcement for RC2 says a mistake was made while packaging RC1, so RC2 was released as the first candidate. The releases feed on php.net now lists 8.6.0 dated 19 Nov 2026, and 8.6 is in the list of supported versions.
That is the PHP side. The framework side is a separate question, and I come back to it near the end.
Features that are in 8.6
Every item here is listed as Implemented on the RFC page, and appears in the release notes or in UPGRADING. I left out RFCs that are still under discussion or in a vote, because they are not part of 8.6.
Partial Function Application
RFC: Partial Function Application v2
You call a function with some arguments and put ? where the rest should go. PHP returns a Closure that takes the missing ones. The ... placeholder works for "all remaining arguments".
php
<?php
$arr = ['hello world', 'bye'];
$result = array_map(str_replace('hello', 'hi', ?), $arr);
// ['hi world', 'bye']
$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];
$supportsPfa = array_filter(
$versions,
version_compare(?, '8.6', '>='),
);This replaces small fn () => wrappers around a call. It also works with the pipe operator from PHP 8.5, which I tried as ' Hello ' |> trim(?) |> strtoupper(?). That returned HELLO. One thing to know: a call that is missing a required argument and has no placeholder is still an error, so str_replace('hello', 'hi') throws an ArgumentCountError as before. The RFC says it is a natural extension of first-class callable syntax from PHP 8.1. The release notes also say array_map() with a partial application callback is compiled into a loop, so there is no intermediate closure on that path.
Time\Duration
Time\Duration is a value object for elapsed time, such as timeouts and retry delays. It is not tied to a date or a timezone, and it has nanosecond precision. Operations that overflow throw Time\TimeException.
php
<?php
use Time\Duration;
$delay = Duration::fromSeconds(1)->add(Duration::fromMilliseconds(100));
time_nanosleep($delay->seconds, $delay->nanoseconds);If you have retry or backoff code that passes around bare integers and a comment saying "microseconds", this is the type that would replace them.
Two details from my test run. A Duration can be negative, but seconds and nanoseconds hold the absolute values, so Duration::fromMilliseconds(1500)->negate() reports 1 and 500000000 and you have to read the negative property to know the sign. And the from* constructors reject negative input: Duration::fromMilliseconds(-1) throws a ValueError. Check the sign before you pass a value to time_nanosleep().
clamp()
php
<?php
clamp(-10, 0, 100); // 0
clamp(50, 0, 100); // 50
clamp(110, 0, 100); // 100It is the same result as max($min, min($max, $value)). It throws a ValueError if the minimum is greater than the maximum, or if a bound is NAN. One practical catch: clamp is now a built-in name, so a userland function with that name in the global namespace will conflict. Helper packages are the usual place to look. In my test, declaring a global clamp() after upgrading was a fatal error, while a namespaced function with the same name was fine. If you maintain a package that must run on both old and new PHP, wrap your own version in if (! function_exists('clamp')) { ... }.
SortDirection enum
A built-in enum with Ascending and Descending cases. The point is that libraries can stop inventing their own sort direction values. A query builder method can type its argument as SortDirection and a wrong value becomes a TypeError instead of failing later inside a match.
Readonly property defaults
RFC: Readonly property defaults
Instance readonly properties can now have a default value. The default counts as the initialization, so the constructor cannot overwrite it.
php
<?php
interface Rule
{
public string $parser { get; }
}
final readonly class SlugRule implements Rule
{
public string $parser = SlugParser::class;
}Before this, you had to assign a fixed value in the constructor.
Polling API
The new Io\Poll classes watch many streams at once using epoll, kqueue, event ports, or WSAPoll, depending on the platform. The release page describes it as a foundation for event loop libraries such as ReactPHP and AMPHP. Here is a small example that I ran, using a socket pair so it does not need a server:
php
<?php
use Io\Poll\{Context, Event};
use Time\Duration;
[$a, $b] = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
$poll = new Context();
$poll->add(new StreamPollHandle($a), [Event::Read], 'conn-a');
fwrite($b, 'hello');
foreach ($poll->wait(Duration::fromMilliseconds(500)) as $watcher) {
echo $watcher->getData(), ': ', fread($a, 5), "\n";
}On Linux, $poll->getBackend() reported Epoll. Adding the same handle twice throws Io\Poll\HandleAlreadyWatchedException. Most Laravel apps will never call it directly. I mention it because it is one of the headline features, and it may reach you through a library, not through your own code.
Stream error handling
RFC: Stream error handling improvements
Stream functions can be set to throw a StreamException, or to stay silent, instead of emitting warnings. Errors come back as StreamError objects with a code (a StreamErrorCode enum case), a message, the wrapperName, a severity, and a terminating flag. There is no path property, so the file name only appears if it is in the message. You can also read them later with stream_last_errors(), but in my test that was empty after a plain failed file_get_contents(). It held the error when I passed a context with error_mode set to StreamErrorMode::Silent.
php
<?php
$context = stream_context_create([
'stream' => [
'error_mode' => StreamErrorMode::Exception,
],
]);
try {
$config = file_get_contents('/etc/app/config.json', context: $context);
} catch (StreamException $e) {
foreach ($e->getErrors() as $error) {
// $error->code is a StreamErrorCode enum case
// $error->message, $error->wrapperName and $error->severity are also set
}
}This is opt-in. Existing code keeps getting warnings.
Smaller additions
These are all in the release notes or UPGRADING:
- Parameter DocComments: a doc comment on a single parameter, readable with
ReflectionParameter::getDocComment(). - ReflectionProperty::isReadable() and isWritable(): answers whether a property can be read or written from a given scope, taking readonly, asymmetric visibility, and hooks into account.
- [#[\Override] on class constants](https://wiki.php.net/rfc/override_constants), including enum cases.
- __debugInfo() on enums.
- Writing to properties of objects stored in constants, for example
Config::DEFAULTS->timeout = 30. The object has to come from a globalconst, such asconst BACKING = new Cfg;followed byclass Config { const DEFAULTS = BACKING; }. In my test, writingconst DEFAULTS = new Cfg;directly inside a class was a fatal error. - The error_include_args INI setting, which adds the passed arguments to error messages. It is off by default, and the notes say sensitive parameters are not shown.
trim(),ltrim(), andrtrim()now strip form feed characters by default.- Several extension additions: URI builder classes, post-quantum key encapsulation in Sodium, TLS session resumption for streams, and
mysqli::quote_string().
Deprecations and breaking changes
This is the section I would spend the most time on. The UPGRADING file is long, and most of it is extension detail. These are the entries a typical web app can hit.
Deprecated in 8.6:
returninside afinallyblock.- Returning a value from
__construct()or__destruct(), and making either of them a generator. letandisas names of classes, functions, or constants, and_as a constant name.- Passing a third argument to
define(). is_double(),is_long(),is_integer(), anddoubleval(). The replacements areis_float(),is_int(), andfloatval().spl_object_hash(). The replacement isspl_object_id().strcoll()andSORT_LOCALE_STRING.metaphone().SplFileObject::fgetcsv(),fputcsv(),setCsvControl(), andgetCsvControl(). In my test the first three also warned that the$escapeparameter must be provided, either explicitly or throughsetCsvControl(), because its default will change.ArrayIteratormethods that were inherited fromArrayObject, includingasort(),ksort(),getFlags(),setFlags(),serialize()andunserialize().spl_classes(). The replacement isReflectionExtension::getClassNames().- Passing an object where an array is expected to
http_build_query()andarray_walk(). Callget_object_vars()first. - Calling
ReflectionProperty::setValue()with an object that is not an instance of the declaring class. - Passing an object to
ReflectionMethod::invoke()for a static method. - A nullable
?arrayreturn type on__debugInfo(). Declarearrayand return an empty array instead ofnull. namespaceas a class constant name, and a function namedreadonly.- The mbstring regex functions such as
mb_ereg(), because the Oniguruma library is no longer maintained. - Using more than 16 filters in a
php://filterURL, unless you raise the limit with a stream context option, for examplestream_context_create(['filter' => ['max_filter_count' => 20]]). A dotted key such asfilter.max_filter_countis not accepted and throws aValueError.
Behavior changes:
- Three session defaults changed:
session.use_strict_modeis now1,session.cookie_httponlyis now1, andsession.cookie_samesiteis nowLax. Laravel configures its session cookies inconfig/session.php, so I would expect less impact there, but any code that uses native PHP sessions directly should be checked. - Many internal functions now throw a
ValueErrorfor out-of-range values or strings with NUL bytes, where they used to truncate or ignore silently. - By-reference
foreachloops may visit elements they used to skip after an array is compacted. It is an edge case, andUPGRADINGlists it as a backward incompatible change.
What I would do before upgrading a Laravel app
First, the framework. The laravel/framework 13.x releases on Packagist declare php: ^8.3. Composer reads that as 8.3 up to, but not including, 9.0, so 8.6 satisfies it and Composer should not stop you. I did not run a full install to confirm. The support table in the Laravel 13 release notes lists PHP 8.3 to 8.5, with no 8.6. As I read it, that table shows the versions the Laravel team supports and tests, not a rule that Composer enforces, and it may change, so look at it again before you plan anything. Third-party packages are where I would expect problems: a package with an explicit upper bound such as php: ">=8.2 <8.6" will refuse to install on 8.6, and I would not use --ignore-platform-reqs on production.
Second, a staging path that does not touch production:
- Add a CI job that runs your test suite on PHP 8.6, and allow it to fail at first.
- Run the tests with
error_reporting(E_ALL)so deprecations show up. - Search your own code, not
vendor/, for the deprecated functions above.spl_object_hash()andis_double()are the two I would search first. - Read the failures that come from
vendor/. Those tell you which packages need a release before you can move.
Third, the timing. According to the php.net supported versions page, PHP 8.5 has active support until 31 December 2027 and security support until 31 December 2029. PHP 8.4 active support ends on 31 December 2026, with security fixes until 31 December 2028. PHP 8.6 itself is listed with active support until 31 December 2028 and security support until 31 December 2030. There is no rush to move on release day. For most apps I would wait for Laravel and the main packages to declare support, then move.
Where I would start experimenting
If I wanted a low-risk first try, I would pick one small, self-contained piece of code and use a new feature only there:
- Replace a hand-written timeout or retry delay with
Time\Duration. - Use
clamp()where you now write nestedmin()andmax(). - Try Partial Function Application in a test or a script, not in core business logic.
None of these require a framework change. They are good ways to learn the new syntax before it shows up in a library you depend on.
Sources
- PHP: PHP 8.6 Release Announcement
- PHP: Releases feed for 8.6
- PHP: Supported Versions
- PHP Wiki: PHP 8.6 release timetable
- PHP Wiki: RFC index
- php-src: UPGRADING on the PHP-8.6 branch
- RFC: Partial Function Application v2
- RFC: Duration class
- RFC: clamp() v2
- RFC: SortDirection enum
- RFC: Readonly property defaults
- RFC: Polling API
- RFC: Stream error handling improvements
- RFC: Parameter DocComments
- RFC: ReflectionProperty isReadable and isWritable
- RFC: Deprecations for PHP 8.6
- RFC: Session security defaults
- Laravel: Release Notes (Laravel 13)
Comments
No comments yet
Loading comments...