New PHP 8.4 release is out: what changed
The developer community has welcomed the long-awaited PHP 8.4 release. This update brings not only long-awaited features but also significant performance improvements that will change the approach to writing modern code. Let's break down the main innovations that everyone working with PHP should know about.
Property Hooks
One of the most discussed innovations is property hooks. Now you can define read and write logic for properties directly in the class without creating separate get/set methods:
- get hook — called when accessing a property, allowing you to compute the value on the fly;
- set hook — called when assigning a value, enabling data validation or transformation;
- The syntax is concise and resembles properties in Kotlin or C#.
This simplifies writing code and makes it more readable, eliminating the need for getters and setters.
Asymmetric Visibility
PHP 8.4 introduces asymmetric visibility for properties. Now you can set different access levels for reading and writing:
- For example,
public private(set) string $name— the property can be read from anywhere but modified only within the class; - This improves encapsulation and code security without extra methods.
JIT Compiler Improvements
The development team has significantly improved the JIT (Just-In-Time compiler). In PHP 8.4:
- Improved performance when working with loops and mathematical operations;
- Reduced memory consumption during compilation;
- The IR (Intermediate Representation) engine has been updated, providing a speed increase of up to 10-15% in some benchmarks.
This is especially important for high-load projects and frameworks.
New Functions and Improvements in the Standard Library
The release includes several useful additions:
- array_find() — a function for finding the first element that satisfies a condition (similar to
array_filter, but returns a single element); - array_all() and array_any() — checking whether all elements or at least one match a callback function;
- mb_ucfirst() — for working with multibyte strings (similar to
ucfirst, but with UTF-8 support).
These functions simplify common tasks and reduce boilerplate code.
Other Important Changes
- Improved typing: added type support for class constants;
- Exception handling optimization: reduced overhead for throw/catch;
- Removal of deprecated functions: some deprecated elements from older versions have been finally removed.
What This Means for Developers
PHP 8.4 is not just a routine update, but a step towards a more modern, performant, and convenient language. Property hooks and asymmetric visibility change the paradigm of working with classes, while JIT improvements make PHP even more competitive in the field of high-load web applications.
We recommend updating your projects to