PHP has been developing at an incredible rate. PHP 8.3 was released in November 2023, marking further advancements in the language's performance, developer experience, and contemporary syntax. Now that PHP 8.4 is anticipated to be released in late 2024, it's time to examine what's novel, intriguing, and useful for regular developers like you and me.
In this post, we’ll explore:
- What PHP 8.3 brought to the table
- What's coming in PHP 8.4 (based on RFCs and current implementation)
- How these updates affect real-world development
Recap: What’s New in PHP 8.3?
First, let's examine the main enhancements and features included in PHP 8.3.
1. Typed Class Constants
Type class constants, a long-awaited feature.
class Config {
public const string ENV = 'production';
}
This strengthens code and aids in the early detection of more errors by static analyzers.
Real-world benefit: This makes contracts much clearer and reduces the possibility of abuse when developing SDKs or shared libraries.
2. Dynamic Class Constant Fetch (ClassName::{EXPR}
)
In earlier stages, dynamic class constant names required undesirable constant() calls. Currently, you can write:
$const = 'STATUS_OK';
echo ResponseStatus::{$const};
Shorter and cleaner. It simply works.
3. #[Override]
Attribute
PHP in the modern era is borrowing from other languages. This property guarantees that you are actually overriding a parent method.
class Base {
public function hello(): void {}
}
class Child extends Base {
#[\Override]
public function hello(): void {} // All good
}
You'll receive a fatal error if the method signature is inconsistent or absent from the parent. Safe coding, which the engine enforces.
4. New json_validate()
Function
Do you wish to verify JSON before decoding it? It's you.
if (json_validate($raw)) {
$data = json_decode($raw, true);
}
A minor but incredibly useful addition that can stop some uncomfortable runtime errors.
5. Performance Boosts & Internal Improvements
- Faster property access
- Better memory handling
- Refined Just-In-Time (JIT) compilation paths All things considered, PHP 8.3 introduced small improvements that speed up and clean up your codebase.
Still unsure between Python VS PHP? Let our experts guide your project to the right stack
What’s Coming in PHP 8.4 (So Far)?
PHP 8.4 is still in development, with a November 2024 release date, but some RFCs have already been accepted, and the direction is promising.
Let's examine the features that developers should be aware of, both confirmed and suggested.
Accepted in PHP 8.4
1. Auto-Capturing Multi-Line Closures
Yes, finally!
$user = 'admin';
$check = fn() {
echo $user; // Now auto-captured!
};
In the past, explicit use clauses were necessary for multi-line closures. Arrow functions will be consistent with PHP 8.4.
This removes a common gotcha and enhances developer ergonomics.
-
mb_str_pad()
Support for multibyte strings instr_pad
has long been a source of annoyance. To properly pad multibyte (such as UTF-8) strings, PHP 8.4 introducesmb_str_pad()
.echo mb_str_pad('你好', 10, '。', STR_PAD_RIGHT);
This is crucial to multilingual applications and APIs.
Building an online store in 2025? Discover how PHP can power your e-commerce success.
Likely Coming (RFCs Under Discussion or Vote)
Though not yet verified, these demonstrate a strong sense of community support and guidance.
Property Hooks / Access Interceptors
PHP may introduce property hooks to read and write native properties without the need for magic, modeled after magic methods like __get()
and __set()
.
class Product {
public int $price {
get => $this->calcPrice();
set => $this->setPrice($value);
}
}
Consider them as engine-enforced getters/setters that are efficient and native.
This has the potential to greatly modernize PHP's OOP and bring it closer to languages like C# and Kotlin.
Fibers Improvements & Better Async Support
The internals of PHP may gain new capabilities related to Fibers and non-blocking IO as frameworks like ReactPHP and AMP develop.
PHP is obviously heading toward full async/await, but don't expect it just yet.
Ready to build with the latest PHP frameworks? Hire a team that knows Laravel, Symfony, and beyond.
Should You Upgrade?
Yes, it's definitely time if you're using PHP 8.1 or lower.
- Security: Active support for PHP 7.x has already ended.
- Performance: Memory and execution time are reduced with each new version.
- Cleaner code: It's well worth the quality-of-life features.
PHP 8.3 is already compatible with the majority of popular frameworks, including Laravel, Symfony, and WordPress.
Real-World Dev Impact
Here’s what these upgrades mean for us on the ground:
| Feature | Why It Matters |
|----------------------------|------------------------------|
| Typed Constants | Better API contracts |
| `#[Override]` | Safer inheritance |
| `json_validate()` | Fewer silent failures |
| Auto-Capturing Closures | Less boilerplate |
| `mb_str_pad()` | Cleaner internationalization |
| Property Hooks *(planned)* | Modern OOP style |
These updates improve maintainability and minimize bugs if you're creating large-scale apps, packages, or anything else that will last.
TL;DR – Release Timeline
Version | Status | Release Date |
---|---|---|
PHP 8.3 | Stable | Nov 2023 |
PHP 8.4 | In Development | Nov 2024 (planned) |
Final Thoughts
PHP’s evolution is proving that it’s far from a "dying language." In fact, it’s maturing faster than ever. From the humble beginnings of PHP 5 to the modern, typed, and performant PHP 8.x series—this is a great time to be a PHP developer.
Stay updated, test early, and give feedback on RFCs when you can. PHP's future is being written with its community.
Top comments (2)
haha.... that's nice :D
Interesting. Thanks for sharing!