Upgrading a Laravel app to PHP 8.6: compatibility, deprecations and tests
Laravel 13.44 is the first release that supports PHP 8.6. This plan covers the support matrix, Composer checks, the PHP 8.6 deprecations that show up in Laravel code, the session and trim() changes, PHPStan and Rector settings, a CI matrix and a staged rollout.
7 min read

In this article
To upgrade a Laravel app to PHP 8.6, first bring the framework to Laravel 13.44 or later, the first release that lists PHP 8.6 support. Laravel 12 and older are not listed for PHP 8.6. For most applications the rest is small: update the framework, confirm that every Composer dependency allows PHP 8.6, clear the new deprecations, and check two behaviour changes that affect input and sessions. This guide is that plan in five stages. The new language features are in what's new in PHP 8.6.
Based on: the PHP 8.6 upgrade notes and supported-versions page, the Laravel 13.44 release notes and support table, and the PHPStan, Rector and setup-php repositories, all read on 26 November 2026.
Where PHP 8.6 stands
PHP 8.6.0 was released on 19 November 2026. It has active support until 31 December 2028 and security fixes until 31 December 2030. Nothing forces a move from 8.5, which keeps active support until 31 December 2027. Two dates matter for older branches: PHP 8.4 leaves active support on 31 December 2026, and PHP 8.2 stops receiving security fixes the same day.
Which Laravel versions support PHP 8.6
Laravel 13.44.0, released on 24 November 2026, added PHP 8.6 support in pull request #61771. The change fixed the deprecations the framework itself triggered on PHP 8.6, including its use of the SORT_LOCALE_STRING flag and strcoll(), and a trimming issue in the validator.
| Laravel | PHP 8.6 | What to do |
|---|---|---|
| 13.44 or later | Supported | Follow the stages below |
| 13.0 to 13.43 | Not listed | Run composer update laravel/framework first |
| 12 | Not listed (8.2 to 8.5) | Upgrade to Laravel 13 first; security fixes for 12 end on 24 February 2027 |
| 11 and older | Not listed | Out of support; upgrade the framework before the PHP version |
On 26 November 2026 the support table in the Laravel documentation still showed PHP 8.3 to 8.5 for Laravel 13. The release notes are the source for 8.6 until the table is updated.
Stage 1: inventory what will change
php -v && php -m # on every server role, not only web
php artisan --version # needs Laravel Framework 13.44 or later
composer why-not php 8.6.0 # packages whose constraints exclude 8.6
composer outdated --direct # direct dependencies with newer releasescomposer why-not php 8.6.0 is the fastest check. An empty result means every installed package declares support for 8.6. Each line it prints is a package to update or replace before you go further.
Check extensions as well. Anything installed through PECL (Redis, Imagick, Xdebug, Swoole and similar) needs a release built for PHP 8.6. Compare the output of php -m on production with what your new image or server provides.
Stage 2: Composer constraints
A constraint of ^8.3 in composer.json already allows PHP 8.6, so the application's own requirement rarely needs to change. Two things do:
- If
config.platform.phppins a version, it must be raised when production moves, or Composer keeps resolving packages for the old PHP. - Run
composer update --dry-runon PHP 8.6 before the real update, and read which packages change major version.
Stage 3: the PHP 8.6 deprecations that show up in Laravel apps
The framework is clean from 13.44. Your own code and older packages are where these appear:
| Deprecated in PHP 8.6 | Where it hides in a Laravel app | Fix |
|---|---|---|
SplFileObject::fgetcsv() and fputcsv() | CSV import and export classes | Open the file with fopen() and use the fgetcsv() and fputcsv() functions |
spl_object_hash() | Caches and registries keyed by object, older packages | spl_object_id() |
is_double(), is_long(), is_integer(), doubleval() | Validation helpers and legacy utilities | is_float(), is_int(), floatval() |
return inside finally | Hand-written retry and cleanup code | Return after the block, so exceptions are not swallowed |
Passing an object to http_build_query() or array_walk() | API clients that pass a DTO or request object | get_object_vars($object) or the object's toArray() |
strcoll() and SORT_LOCALE_STRING | Locale-aware sorting of names | Collator from the intl extension |
mb_ereg(), mb_split() and the other mbstring regex functions | Older text-processing code | preg_* with the u modifier |
Session handlers without create_sid() and validateId() | Custom session drivers registered with Session::extend() | Implement both methods on the handler class |
A search of your own code finds most of them in a minute:
grep -rnE "is_double\(|is_long\(|is_integer\(|doubleval\(|spl_object_hash\(|strcoll\(|SORT_LOCALE_STRING|metaphone\(|mb_ereg|mb_split\(|->fgetcsv\(|->fputcsv\(|stmt_init\(" app bootstrap config database routes testsDeprecations raised inside vendor/ are fixed by updating the package. If the newest release still triggers one, report it to the maintainer; do not patch vendor code.
Two behaviour changes to check by hand
Session defaults. PHP 8.6 turns on session.use_strict_mode and session.cookie_httponly and sets session.cookie_samesite to "Lax". Laravel does not use PHP's native sessions: its session cookie is created by the framework from config/session.php, so these INI changes do not alter the Laravel session. They do affect any code in the same PHP pool that calls session_start() itself, such as a legacy admin area or a single sign-on or payment library. Confirm what the server will use, and check the PHP-FPM pool as well, because the command line and PHP-FPM can load different INI files:
php -i | grep -E "session\.(use_strict_mode|cookie_httponly|cookie_samesite)"Trimming and file writes. trim() now also removes the form feed character, and fclose(), file_put_contents() and copy() return false when flushing or closing fails instead of hiding the failure. Code that checks those return values will start to see real errors, such as a full disk, that were invisible before. Several functions also throw a ValueError for input they used to accept quietly, for example a path containing a NUL byte passed to file_exists(); that matters wherever a path comes from user input.
Stage 3 continued: PHPStan and Rector
Static analysis finds deprecated calls that tests never reach. PHPStan accepts PHP 8.6 as a target from version 2.2; version 2.1 stops at 8.5. Set the version explicitly so the result does not depend on the PHP that runs the tool:
# phpstan.neon
parameters:
phpVersion: 80600Rector has added a level set for PHP 8.6. Update Rector first and confirm your version includes it, then enable it the same way as for earlier versions; the configuration and the pitfalls are in the PHP 8.5 upgrade guide, and the PHPStan tutorial covers levels and baselines. Run Rector with --dry-run and review the diff before applying it.
Stage 4: make deprecations fail the test suite, and test both versions
A deprecation does not fail a test unless you ask for it. Set failOnDeprecation="true" on the <phpunit> element in phpunit.xml for the length of the upgrade, as described in the 8.5 guide, then run the suite on both versions in CI:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.5', '8.6']
steps:
- uses: actions/checkout@v5
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- run: composer install --no-interaction --prefer-dist
- run: php artisan testKeep both versions in the matrix until production has moved. For containers, the official image has PHP 8.6 tags such as php:8.6-fpm-bookworm and php:8.6-cli. Test by hand what automated tests rarely cover: file uploads, CSV import and export, queued jobs, scheduled commands, and any login that goes through an external provider.
Stage 5: rollout
- Deploy to staging on PHP 8.6 and run it for a few days with real jobs and scheduled tasks.
- Watch the logs for lines containing
Deprecatedand for newValueErrorexceptions. - Move one production worker or one queue first, then the web tier.
- Restart everything that keeps PHP in memory: PHP-FPM, queue workers (
php artisan queue:restart) and Horizon (php artisan horizon:terminate). - Keep the PHP 8.5 image or packages until the new version has run clean through a full business cycle, so rolling back is one deploy.
The Laravel 13 production deployment checklist covers the release steps themselves. If you would rather hand the upgrade over, see our Laravel development service.
When not to upgrade a Laravel app to PHP 8.6 yet
- You are on Laravel 12 or older. Upgrade the framework first.
composer why-not php 8.6.0lists a package you cannot update or replace.- An extension you load has no release for PHP 8.6.
- The test suite does not yet pass on 8.6 with deprecations treated as failures.
PHP 8.6.0 is also the first release of its branch. If you prefer to wait for the first bug-fix releases before production, use the time to finish stages 1 to 4 in CI, so the move itself is a version change and nothing else.
Frequently asked questions
Which Laravel version do I need for PHP 8.6?
Laravel 13.44.0 or later. It was released on 24 November 2026 and is the first release whose notes list PHP 8.6 support.
Does Laravel 12 support PHP 8.6?
Laravel 12 is listed for PHP 8.2 to 8.5, and the PHP 8.6 support change was made for Laravel 13 only. Upgrade to Laravel 13 before moving to PHP 8.6.
Do the new session defaults in PHP 8.6 affect Laravel?
Not the Laravel session itself. Laravel does not use PHP's native sessions; it sets its own cookie from
config/session.php. The new defaults affect code that callssession_start()directly, such as a legacy area of the same site or some sign-on and payment libraries.Do I need to change the PHP constraint in composer.json to use PHP 8.6?
Usually not. A constraint such as
^8.3already allows 8.6. Ifconfig.platform.phppins a version, raise it when production moves, and runcomposer why-not php 8.6.0to find dependencies that exclude 8.6.How long is PHP 8.6 supported?
PHP 8.6 was released on 19 November 2026. It has active support until 31 December 2028 and security fixes until 31 December 2030.
Sources
- PHP 8.6 upgrade notes (UPGRADING) — php-src
- PHP 8.6 Release Announcement — The PHP Group, 2026-11-19
- Supported Versions — The PHP Group
- Laravel framework v13.44.0 release notes — Laravel, 2026-11-24
- [13.x] Supports for PHP 8.6 (#61771) — Laravel
- Laravel release notes and support policy — Laravel
- RFC: Session security defaults — PHP RFC
- RFC: Deprecations for PHP 8.6 — PHP RFC
- setup-php — GitHub
- PHPStan configuration reference — PHPStan
Written with substantial AI assistance. Facts checked against cited sources. Editorial policy.
Read next

PHP8 min read
What's new in PHP 8.6: partial function application, clamp(), Duration and more
PHP 8.6 adds partial function application, clamp(), a Time\Duration class, readonly property defaults and a SortDirection enum, and makes sessions stricter by default. Each feature with a short example, then the behaviour changes and deprecations to fix before upgrading.
New tools, once a week
One short email listing what joined the directory.
Comments
No comments yet. Be the first to join the conversation.
Leave a comment
Every comment is read by a moderator before it appears. Your email address is never published; it is used only to contact you about this comment.
More from Cloudsoft Zone

Industry updateCodeIgniter6 min read
CodeIgniter 4.7.6 security release: what to patch and how
CodeIgniter 4.7.6 fixes four security advisories: SQL injection through named binds, a mass assignment bypass in Model::replace(), and path traversal in the file cache and sanitize_filename(). Who is exposed, what changes in behaviour, and how to upgrade from 4.7.5.
By Nilesh Kushvaha

TutorialDevOps5 min read
MySQL production configuration for Laravel applications: a safe operating baseline
Review MySQL production configuration for Laravel using measured memory and connection budgets, explicit durability, protected access and verified restore procedures.
By Nilesh Kushvaha

TutorialDevOps4 min read
Structured logging in Laravel and NestJS: a production event contract
Implement structured logging with stable event names, safe fields and request correlation across Laravel and NestJS, then verify collector behavior and retention.
By Nilesh Kushvaha