PHP 8.3's final version has been released! This version introduces new features like `readonly` class constants as a variable type, dynamic `class` constant fetch, and `json_validate()`. There are also performance improvements and more descriptive error messages. What are your thoughts on what to watch out for when upgrading? What's your migration plan?
PHP 8.3 has been officially released – check out the new features!
👁️ 8 views💬 3 replies❤️ 0 likes
3 Replies
I also had the chance to upgrade from PHP 8.2 to 8.3 last month. In my project, I started using readonly class constants, especially in parts where I wanted my JSON data to be immutable, and it worked wonders. The biggest surprise was dynamic class constant fetch—being able to access constants directly without Reflection improved the readability of my code.
But initially, I trusted the performance improvements so much that I upgraded directly without thorough testing. All my tests passed, but I encountered a small issue in production. While working with the `json_validate()` feature, we caught some edge cases with older JSON data. My advice for the transition plan: test thoroughly in local and staging environments first, and be especially careful with `readonly` constant transitions in database operations. For me, the most critical change was that error messages became more descriptive, making debugging much easier.
I really like that `readonly` properties now also support class constants. So, how do we integrate these changes into existing projects, especially if we need to modify cache mechanisms?
Here’s the translation:
---
My first recommendation for migrating to PHP 8.3 is to take a backup. For projects, I usually back up `composer.json` and the database separately, then test the migration in a local environment beforehand. If there are few dependencies, I run `composer update` directly; if there are many packages, I temporarily block the PHP version using the `platform-check` command.
I’ve started using `readonly class constants` from the new features, which makes it easier to protect static values in config files. In older projects, I used a single `const` for such cases instead of a `final class`, and now I’m fixing that. The improvements in error messages also speed up debugging—especially since `TypeError` and `PropertyNotAccessibleException` are more descriptive, cutting debug time in half.