Get your next remote job on LaraJobs.

PHP 8.4: new features and release date

Benjamin Crozat
Modified on Dec 22, 2023 0 comments Edit on GitHub
PHP 8.4: new features and release date


PHP is an open-source project. Knowing what’s going on for PHP 8.4 only takes a minute of research. For instance, this page lists all the accepted RFCs for different versions of PHP, including PHP 8.4.

When will PHP 8.4 be released?

PHP 8.4 will be released on November 21, 2024, according to the preparation tasks list. It will be tested through three alpha releases, three betas, and six release candidates.

Date Release of PHP 8.4
June 6, 2024 Alpha 1
June 20, 2024 Alpha 2
July 4, 2024 Alpha 3
July 16, 2024 Feature freeze
July 18, 2024 Beta 1
August 1, 2024 Beta 2
August 15, 2024 Beta 3
August 29, 2024 RC 1
September 12, 2024 RC 2
September 26, 2024 RC 3
October 10, 2024 RC 4
October 24, 2024 RC 5
November 7, 2024 RC 6
November 21, 2024 GA

Install and test PHP 8.4 on macOS

  1. Install the Homebrew package manager if it’s not done already.
  2. Run brew update to make sure Homebrew and the formulae are up to date.
  3. Add a new tap (basically a GitHub repository) for PHP 8.4’s formula: brew tap shivammathur/php.
  4. Install the pre-compiled binary for PHP 8.4 (also called “a bottle” in Homebrew’s context). This will make the install so much faster. brew install php@8.4.
  5. Link it to make sure that the php alias targets the right binary: brew link --overwrite --force php@8.4.

If you want to learn more about how to install PHP on your Mac, I wrote something for you: PHP for Mac: get started fast using Laravel Valet

What’s new in PHP 8.4

PHP 8.4’s DOM extension now supports HTML5

PHP 8.4’s DOM extension just got a big upgrade with support for HTML5 parsing and serialization. This means no more headaches when dealing with HTML5 specific tags or embedding HTML in your JavaScript.

Just use the new DOM\HTMLDocument class and your HTML5 content will be handled correctly, keeping up with the modern web standards.

Here’s how you create an HTML document from a string:

use DOM\HTMLDocument;

$htmlDocument = HTMLDocument::createFromString('<!DOCTYPE html><html><body>Hello, HTML5!</body></html>');

Or from a file:

use DOM\HTMLDocument;

$htmlDocument = HTMLDocument::createFromFile('path/to/your/file.html');

Learn more: PHP RFC: DOM HTML5 parsing and serialization

PHP 8.4 comes with an increased bcrypt cost by default

In PHP 8.4, the default cost of bcrypt has been increased to 12. What does that even mean?

Bcrypt is the password hashing function that PHP uses. It acts as a shield against hackers who would want to crack passwords.

The strength of this shield can be adjusted. The higher the setting or the “cost”, the stronger the shield because bcrypt is an adaptive function: “over time, the iteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with increasing computation power.”

And why is it such a big deal? Because increasing the cost of bcrypt makes password hashing a few milliseconds slower.

Learn more: PHP RFC: Increasing the default BCrypt cost

PHP 8.4 can parse large XML documents more reliably

This change resolved a potential issue in the ext/xml PHP extension involving its handling of large XML document parsing.

Conflicting modifications in libxml2 version 2.7.0 unintentionally disrupted large document parsing when using xml_parse() and xml_parse_into_struct() functions, resulting in a parsing error.

PHP 8.4 introduced a new parser option to properly handle these large XML documents and prevent the parsing error, making it possible for developers to parse large XML documents effectively, without needing complex workarounds.


New multibyte trimming functions in PHP 8.4

PHP 8.4’s mbstring extension now includes three new functions: mb_trim(), mb_ltrim(), and mb_rtrim(). This addition makes it easier to trim strings with multibyte characters, improving upon the previous workaround of using regex with preg_replace().

The new functions handle whitespace and other characters in a multibyte safe way. The default behavior removes a predefined set of characters which includes various types of space characters, including some that are not typically covered by \s in regular expressions.

Here are the functions in PHP 8.4 and their default behaviors:

  • mb_trim($string, $characters): Trims characters from both ends of a string.
  • mb_ltrim($string, $characters): Trims characters from the beginning (left side) of a string.
  • mb_rtrim($string, $characters): Trims characters from the end (right side) of a string.

By default, $characters includes a variety of whitespace characters, but not all possible Unicode characters due to storage and compatibility concerns.

Learn more: PHP RFC: Multibyte for trim function mb_trim, mb_ltrim and mb_rtrim

Wait, there's more!

Be the first to comment!

Get help or share something of value with other readers!

Great deals for enterprise developers
  • ZoneWatcher
    Get instant alerts on DNS changes across all major providers, before your customers notice.
    25% off for 12 months using the promo code CROZAT.
    Try ZoneWatcher for free
  • Quickly build highly customizable admin panels for Laravel projects.
    20% off on the pro version using the promo code CROZAT.
    Try Backpack for free
  • Summarize and talk to YouTube videos. Bypass ads, sponsors, chit-chat, and get to the point.
    Try Nobinge →
  • Monitor the health of your apps: downtimes, certificates, broken links, and more.
    20% off the first 3 months using the promo code CROZAT.
    Try Oh Dear for free
  • Keep the customers coming; monitor your Google rankings.
    30% off your first month using the promo code WELCOME30
    Try Wincher for free →
The latest community links
- / -