1. 🔄 Property Hooks
-
Introduces
__getProperty()
and__setProperty()
magic methods. -
Lets you hook into property access without using overloading:
phpclass MyClass { public function __getProperty(string $name): mixed { // Custom logic } public function __setProperty(string $name, mixed $value): void { // Custom logic } }
2. 🔐 Asymmetric Visibility for Class Constants
-
You can now define
public
,protected
, orprivate
get/set visibility separately:phppublic const string $value { get; private set; }
3. 🧱 Database Driver-Specific PDO Subclasses
-
Adds better abstraction and features for each database:
-
\PDO\MySQL
,\PDO\PostgreSQL
, etc.
-
-
Improves type safety and provides specific driver methods.
4. 💤 Lazy Objects
-
Lazy initialization of objects with the new
Lazy
attribute:php#[Lazy] public SomeHeavyClass $service;
5. 🌐 HTML5 Support in DOM Extension
-
Better handling of HTML5 elements in DOMDocument and related classes.
-
Improves parsing and encoding.
6. 📉 Deprecations
Some functions and behaviors are deprecated to clean up legacy PHP, including:
-
Deprecated dynamic properties (continued from 8.2).
-
Deprecated partially supported syntax.
7. 🧠 Miscellaneous Improvements
-
Performance improvements via the JIT engine.
-
Better error messages and stack traces.
-
Internal engine refinements and reduced memory usage.
🧪 Compatibility
PHP 8.4 is mostly backward-compatible with 8.3, but:
-
Some legacy behaviors (like dynamic properties on non-
#[AllowDynamicProperties]
classes) may now emit warnings or be removed. -
It’s wise to test your code thoroughly before upgrading.
Would you like a detailed migration guide or a checklist to upgrade your current PHP app to 8.4 safely