DevOps & monitoring

PHP 8.6 tightens security defaults and deprecates legacy functions

PHP 8.6 introduces stricter session security, new TLS features, and deprecates several legacy functions and aliases to modernize the language.

Server rack with security shield and expiry calendar
Illustration created for this article

The PHP development team has released version 8.6, marking a significant shift toward stricter security defaults and modern cryptographic standards. This update, announced in November 2026, introduces enhanced TLS capabilities, post-quantum cryptography support, and a wave of deprecations aimed at cleaning up the language’s legacy surface area. Developers maintaining self-hosted applications will need to review their configurations and codebases to ensure compatibility with these new baseline requirements.

What happened

PHP 8.6 arrives with substantial changes to how the language handles transport layer security and session management. The release adds support for TLS 1.3 early data, also known as 0-RTT, along with session resumption and external pre-shared keys for TLS streams. On the cryptographic front, the Sodium extension now includes post-quantum key encapsulation mechanisms, specifically X-Wing and ML-KEM-768, as well as IP address encryption and new extendable-output functions like SHAKE and TurboSHAKE. These additions position PHP to better handle future security threats and high-performance secure connections.

Simultaneously, the release enforces stricter security defaults for sessions. The configuration now enables session.use_strict_mode and session.cookie_httponly by default, while setting session.cookie_samesite to Lax. Custom session handlers that fail to implement both create_sid() and validateId() methods are now deprecated, pushing developers toward more robust session management practices. Additionally, many functions that previously failed silently now throw a ValueError when encountering out-of-range values or invalid flags, making debugging more predictable but requiring tighter error handling in existing code.

Key details

  • TLS streams now support session resumption, external pre-shared keys, and TLS 1.3 early data (0-RTT).
  • The Sodium extension adds post-quantum key encapsulation (X-Wing and ML-KEM-768) and IP address encryption.
  • Session security is hardened by default with session.use_strict_mode and session.cookie_httponly enabled.
  • Using return inside a finally block is deprecated because it silently discards exceptions.
  • Mbstring regular expression functions like mb_ereg() are deprecated due to the unmaintained Oniguruma library.
  • Functions such as fclose() and file_put_contents() now return false on failure instead of ignoring errors.

Background

For teams running self-hosted PHP applications, understanding the implications of TLS 1.3 early data is crucial. This feature allows clients to send data before the TLS handshake is complete, reducing latency for repeated connections. However, it introduces replay attack risks if not handled correctly by the application logic. Similarly, post-quantum cryptography addresses the threat posed by future quantum computers, which could break current public-key encryption standards. By integrating these algorithms now, PHP ensures that long-lived secrets remain secure against emerging computational capabilities.

Deprecations in PHP often signal the end of life for older, less secure, or poorly maintained components. The removal of mbstring regex functions, for instance, stems from the lack of maintenance in the underlying Oniguruma library. Developers are encouraged to migrate to PCRE functions with the u modifier, which offer better performance and active support. Understanding these shifts helps teams plan their migration strategies without being caught off guard by sudden breaks in future major versions.

Why it matters

Self-hosting teams must pay close attention to the new session defaults. Enabling strict mode and HttpOnly cookies by default improves security out of the box, protecting against session fixation and cross-site scripting attacks. However, applications relying on custom session handlers may break if they do not implement the required methods. This change forces a review of session management code, ensuring that all handlers meet the new security standards. Failure to update could result in runtime deprecation warnings or eventual failures in future releases.

The shift from silent failures to explicit exceptions also impacts operational stability. Functions like fclose() now return false when flushing fails, rather than ignoring the error. This behavior change means that existing code assuming successful operations must be updated to check return values or catch exceptions. For DevOps engineers, this translates to more accurate logging and monitoring, but it requires immediate code audits to prevent unexpected crashes in production environments. The inclusion of location information in JSON error messages further aids in rapid debugging, reducing mean time to resolution for parsing issues.

What you can do

  • Audit custom session handlers to ensure they implement both create_sid() and validateId() methods.
  • Review code for usage of return in finally blocks and refactor to avoid silent exception discarding.
  • Replace deprecated mbstring regex functions with PCRE equivalents using the u modifier.
  • Update error handling logic to account for ValueError exceptions from functions receiving invalid inputs.
  • Test TLS configurations to leverage new 0-RTT capabilities while mitigating replay attack risks.
  • Check for usage of deprecated aliases like is_double() and replace them with standard types like is_float().

More news

All news