New PHP 8.4 Standard: Key Changes for Developers

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

New PHP 8.4 Standard: Overview of Key Innovations



The world of web development is in anticipation again: PHP 8.4, another major version of the most popular server-side language, promises to be a significant step forward. Although the official release is scheduled for the end of 2024, it is already possible to evaluate the key changes that will affect the daily work of developers. In this article, we will break down the most important aspects.



Property Hooks: Long-Awaited Conciseness



Perhaps the most discussed innovation is property hooks. They allow you to define the logic for getting (get) and setting (set) a value directly in the property declaration, without writing cumbersome getters and setters.



  • Code Simplification: Instead of creating separate methods, you write the logic inside the property. The code becomes cleaner and shorter.
  • Improved Readability: Validation or data transformation logic is now located next to the variable declaration.
  • Flexibility: You can create both computed properties (only get) and properties with validation on write.


Example: previously, to validate a user's age, you needed to write a setAge() method. In PHP 8.4, this can be done directly in the property: public int $age { set => $value >= 0 ? $value : 0; }. This changes the approach to class design.



Asynchrony: Moving Towards Modernity



Although PHP has historically been a synchronous language, the community is actively moving towards supporting asynchronous programming. PHP 8.4 takes an important step by introducing improved support for Fibers and new functions for working with non-blocking I/O.



  • Fibers: Allow you to pause and resume function execution without blocking the entire process.
  • Non-blocking Streams: Simplify writing high-load applications such as web sockets or asynchronous APIs.
  • Compatibility: The new mechanisms do not break old code but open doors for modern patterns.


This does not make PHP fully asynchronous like JavaScript, but it gives developers tools for more efficient work with concurrency.



JIT and Performance Improvements



Just-In-Time (JIT) compilation, which first appeared in PHP 8.0, receives significant improvements. In version 8.4, the core development team has optimized its operation, leading to increased code execution speed in real-world projects.



  • Loop Optimization: JIT handles long iterations better.
  • Reduced Overhead: Time for compilation and memory management has been decreased.
  • Speedup of up to 10-15%: In some synthetic benchmarks, performance gains are noticeable even on regular web pages.


For developers, this means that existing code without changes may start running faster after upgrading to the new version.



What Else Should You Know?



In addition to the main features, PHP 8.4 includes many minor but pleasant improvements:



  • New Array Functions: Simplify sorting and filtering.
  • Improved Typing:

Recommended Libraries