PHP 8.4 Release Date & Features – What’s New in Store for Us

PHP 8.4 Release

PHP is the mastermind behind various web applications. Its latest version, PHP 8.4, will be released on November 21, 2024. Users can hope to witness a plethora of impressive features and improvements. From the developers’ perspective, they can benefit from more improved and impactful features, allowing them to make their web development processes results-driven.

This blog post will explain the PHP 8.4 release, what’s new in it, and why this release is crucial for improving web development in the future.

PHP 8.4 Release (New Features and Improvements)

As mentioned, the PHP 8.4 release date is November 21, 2024. It is the latest version compared to previous PHP versions.

PHP 8.4 will delight users with numerous impactful features and enhancements. For instance, they can smartly utilize new array functions, such as:

  • ‘array_ find()’
  • ‘array_find_key()’
  • ‘array_any()’
  • ‘array_all()’

Besides, there are other incredible PHP 8.4 features which will grab users’ attention from the word go, including:

  • Property Hooks
  • Asymmetric Visibility
  • MyClass()->method() Without Parentheses
  • JIT Changes
  • HTML5 Support
  • Other PHP 8.4 features to watch

Property Hooks

Properties in PHP objects have offered various benefits to PHP developers. For example, they help them implement value validations. For that reason, property types starting in PHP 7 have greatly helped this.

Still, the fact that validation must, by necessity, happen via a method has led to many boilerplates in the form of getters and setters or abuse of the __get and __set magic methods.

In reality, read-only properties in PHP 8 resolve numerous issues for developers. They can guard values through the constructor and still offer fully typed properties for direct access.

Property Hooks also offers a robust feature for working with PHP class properties. Properties can optionally explain one or more hooks, currently limited to “get” and “set,” enabling you to hook into the property’s lifecycle. Here is an example from the RFC:

class User implements Named
{
    private bool $isModified = false;
    public function __construct(private string $first, private string $last) {}
    public string $fullName {
        // Override the "read" action with arbitrary logic.
        get => $this->first . " " . $this->last;
        // Override the "write" action with arbitrary logic.
        set {
            [$this->first, $this->last] = explode(' ', $value, 2);
            $this->isModified = true;
        }
    }
}

Asymmetric Visibility

Asymmetric visibility is an innovative feature that helps developers explain differing visibility for various operations on a property. This allows them to smartly gain control over the visibility of class members, such as properties and methods.

For instance, you can suggest that you wish to allow public read access to a property, however, only allow modifications to it internally:

public private(set) string $bar = ‘baz’;

Asymmetric visibility works in parallel with the changes presented with property hooks, including the ability to describe visibility in interfaces.

MyClass()->method() Without Parentheses

A common practice in PHP is instantiating a class instance and accessing a method or property without delay. Here is the example below:

$request = (new Request())->withMethod(‘GET’)->withUri(‘/hello-world’);

We must wrap the class in parentheses when instantiating it, which is the PHP engine’s requirement. Through PHP 8.4, users can omit such parentheses, offering a more user-friendly usage:

$request = new Request()->withMethod(‘GET’)->withUri(‘/hello-world’);

 JIT Changes

PHP 8.4 has changed the way the JIT is activated. Users had to set opcache.jit_buffer_size to 0 to deactivate the JIT previously. However, you can deactivate it as described below:

opcache.jit=disable

opcache.jit_buffer_size=64m

This change will affect users if they had specified a opcache.jit_buffer_size but did not specify opcache.jit. In this situation, users will need to incorporate opcache.jit=tracing to activate the JIT again. Besides, users will witness improvements to the JIT, making it run smoothly and fastly.

HTML5 Support

PHP 8.4 includes a \Dom\HTMLDocument class that can parse HTML code efficiently. The outdated \DOMDocument class is still accessible for backward compatibility.

$doc = \Dom\HTMLDocument::createFromString($contents);

For developers who parse or build HTML using the DOM extension, this release will provide various innovative yet results-driven features and robust support for HTML5.

PHP 8.4 Deprecations

With PHP 8.4 new features and enhancements aside, a few deprecations will occur. These deprecations are implicit nullable types and deprecation of GET/POST sessions.

Implicit Nullable Types

Previously, a typed variable with a default null value in PHP could have been made nullable automatically:

function foo(T1 $a, T2 $b = null, T3 $c) {}

When nullable types were included, this signature could have been explicitly obtained:

function bar(T1 $a, ?T2 $b = null, T3 $c) {}

Or through a union type:

function test(T1 $a, T2|null $b = null, T3 $c) {}

This implicit declaration worked without fuss previously. However, it has now been deprecated in PHP 8.4.

Deprecation of GET/POST Sessions

Web applications track user states utilizing cookies. In PHP, web applications perform this action through GET and POST parameters. For this purpose, users must deactivate the “session.use_only_cookies” setting, utilizing the features implemented in browsers before cookies.

In this scenario, a mechanism known as “session. use_trans_side” is enabled to help identify a session token in any user’s cookies or POST or GET parameters. “session.use_only_cookies” is activated by default, and “session.use_trans_sid” is deactivated. PHP 8.4 will alert a deprecation warning if either value is toggled differently.

PHP 8.4 Other Impressive Features

Here are other impressive features users will benefit from, including:

  • $_POST and $_FILES now support additional HTTP verbs.
  • Multibyte trim functions: mb_trim(), mb_ltrim(), and mb_rtrim().
  • New, more precise, rounding modes for the round() function.
  • Driver-specific PDO subclasses to allow access to driver-specific features.
  • Improved callbacks for DOM and XSL, enabling closures, first-class callables, and instance methods.
  • The addition of Lazy Object support provides low-level features for generating ghost objects, proxies, and more; frameworks and ORMs will generally consume these for use with dependency injection containers and object hydration.
  • A new engine attribute, #[Deprecated], for marking deprecated functionality.
  • Several improvements to the BCMath, GMP, and DOM extensions.

PHP 8.4 Release Date Timeline (Snapshot)

As you know, the expected PHP 8.4 release date is 21 Nov 2024. For user’s ease, here is the PHP 8.4 release timeline:

Release DateMilestone
July 04, 2024Alpha Release 1
July 18, 2024Alpha Release 2
August 01, 2024Alpha Release 3 (Skipped)
August 1, 2024Alpha Release 4
August 13, 2024Feature Freeze
August 15, 2024Beta Release 1 (Skipped)
August 15, 2024Beta Release 2 (Skipped)
August 15, 2024Beta Release 3
August 29, 2024Beta Release 4
September 12, 2024Beta Release 5
September 26, 2024Release Candidate 1
October 10, 2024Release Candidate 2
October 24, 2024Release Candidate 3
November 7, 2024Release Candidate 4
November 21, 2024General Availability Release

Will There Be a PHP 9?

PHP 9 release date can be expected in 2025. However, the official PHP release date has not been confirmed yet. Furthermore, specific improvements and features may change based on ongoing discussions and community feedback.

To maximize PHP, users must understand other languages, such as HTML and CSS. By doing so, they can reap the rewards through continuous growth, potentially building top-notch yet result-oriented sites.

Wrapping Up

We hope you liked our comprehensive blog post describing the PHP 8.4 release, its new and impactful features, and improvements. The upcoming version signifies the importance of this popular programming language.

PHP 8.4 illuminates the continuous adaptation and growth of the dynamic web development landscape. Therefore, users must be smart enough to experience exciting features and improvements in the forthcoming version.

Developers can utilize PHP 8.4’s capabilities to take their web application development game to unprecedented heights. In addition, PHP 8.4 demonstrates its dedication to performance, output, and, most importantly, security in terms of profitability.

Share This Article