Skip to main content

Cloudsoft Zone Build, deploy and scale with practical guides to PHP, Node.js, React, DevOps and AI automation. Explore the guides

Cloudsoft Zone
PHPDevelopmentDevOpsLaravelTutorial

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.

Nilesh Kushvaha

7 min read

Cloudsoft Zone cover: upgrade a Laravel app to PHP 8.6
Image: Cloudsoft Zone
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.

LaravelPHP 8.6What to do
13.44 or laterSupportedFollow the stages below
13.0 to 13.43Not listedRun composer update laravel/framework first
12Not listed (8.2 to 8.5)Upgrade to Laravel 13 first; security fixes for 12 end on 24 February 2027
11 and olderNot listedOut 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

Shell
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 releases

composer 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.php pins a version, it must be raised when production moves, or Composer keeps resolving packages for the old PHP.
  • Run composer update --dry-run on 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.6Where it hides in a Laravel appFix
SplFileObject::fgetcsv() and fputcsv()CSV import and export classesOpen the file with fopen() and use the fgetcsv() and fputcsv() functions
spl_object_hash()Caches and registries keyed by object, older packagesspl_object_id()
is_double(), is_long(), is_integer(), doubleval()Validation helpers and legacy utilitiesis_float(), is_int(), floatval()
return inside finallyHand-written retry and cleanup codeReturn 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 objectget_object_vars($object) or the object's toArray()
strcoll() and SORT_LOCALE_STRINGLocale-aware sorting of namesCollator from the intl extension
mb_ereg(), mb_split() and the other mbstring regex functionsOlder text-processing codepreg_* 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:

Shell
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 tests

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

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

YAML
# phpstan.neon
parameters:
    phpVersion: 80600

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

YAML
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 test

Keep 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

  1. Deploy to staging on PHP 8.6 and run it for a few days with real jobs and scheduled tasks.
  2. Watch the logs for lines containing Deprecated and for new ValueError exceptions.
  3. Move one production worker or one queue first, then the web tier.
  4. Restart everything that keeps PHP in memory: PHP-FPM, queue workers (php artisan queue:restart) and Horizon (php artisan horizon:terminate).
  5. 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.0 lists 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 calls session_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.3 already allows 8.6. If config.platform.php pins a version, raise it when production moves, and run composer why-not php 8.6.0 to 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

  1. PHP 8.6 upgrade notes (UPGRADING) — php-src
  2. PHP 8.6 Release Announcement — The PHP Group, 2026-11-19
  3. Supported Versions — The PHP Group
  4. Laravel framework v13.44.0 release notes — Laravel, 2026-11-24
  5. [13.x] Supports for PHP 8.6 (#61771) — Laravel
  6. Laravel release notes and support policy — Laravel
  7. RFC: Session security defaults — PHP RFC
  8. RFC: Deprecations for PHP 8.6 — PHP RFC
  9. setup-php — GitHub
  10. PHPStan configuration reference — PHPStan

Written with substantial AI assistance. Facts checked against cited sources. Editorial policy.

New tools, once a week

One short email listing what joined the directory.

The weekly email about new tools and occasional newsletters. Unsubscribe at any time.

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.

Never published. Used only to contact you about this comment.

Loading the security check…

Comments are moderated before publication.