The API Guys
PHP 8.4 logo with upward arrows representing upgrades and security improvements
·6 min read·The API Guys

PHP 8.4 - Are You Running It Yet?

PHPSecurityLaravelPerformanceSoftware UpdatesWeb Development

PHP 8.4 landed on 21st November 2024, and it is comfortably one of the most feature-rich releases the language has seen in years. If you are still running 8.2 or 8.3 - or worse, something older - now is the time to start planning your upgrade. Not just for the shiny new syntax, but for the security and performance improvements that come with staying current.

We build APIs for a living, and PHP is at the heart of almost everything we do. So when a new version drops, we pay attention. Here is what caught our eye in 8.4, and why we think you should care too.

Property Hooks - The Headline Feature

Property hooks are arguably the biggest change to PHP's object model in years. They let you define get and set behaviour directly on a class property, without needing to write separate getter and setter methods. If you have ever written a class with dozens of boilerplate getX() and setX() methods just to add a bit of validation or transformation, this one is for you.

Here is a quick example:

class User { public string $email { set(string $value) { $this->email = strtolower(trim($value)); } } }

Gone is the need for a dedicated setter method. The hook runs automatically whenever the property is assigned a value. This is a pattern that developers working with frameworks like Laravel will recognise from Eloquent accessors and mutators, but now it is baked into the language itself. It means cleaner, more readable code with less boilerplate - something we are always striving for in our API projects.

Asymmetric Visibility

Another feature that reduces boilerplate is asymmetric visibility. You can now define different visibility levels for reading and writing a property. The most common use case is a property that is publicly readable but can only be set from within the class:

class Order { public private(set) string $status = 'pending'; }

Previously, you would need a private property with a public getter method to achieve this. Asymmetric visibility makes that pattern a one-liner. For API development, where data transfer objects and value objects are everywhere, this is a genuine quality-of-life improvement.

New DOM API with HTML5 Support

PHP's DOM extension has been stuck on HTML 4.01 for far too long. PHP 8.4 introduces a new DomHTMLDocument class with proper HTML5 parsing support. If you have ever tried to parse modern HTML with DOMDocument and been frustrated by the warnings and quirks, you will appreciate this change. The old classes remain for backwards compatibility, but the new API is spec-compliant and much more pleasant to work with.

Quality of Life Improvements

Beyond the headline features, there is a collection of smaller improvements that add up to a noticeably better developer experience:

  • Method chaining on new without parentheses - You can now write new Request()->withMethod('GET') instead of wrapping the instantiation in brackets. It is a small thing, but it removes a common source of friction.
  • New array functions - array_find(), array_find_key(), array_any(), and array_all() bring functional-style array operations that many developers have been implementing manually for years.
  • Multibyte trim functions - mb_trim(), mb_ltrim(), and mb_rtrim() finally provide proper multibyte support for string trimming.
  • Improved JIT compilation - The JIT has been rebuilt on an IR framework, bringing better performance for computation-heavy workloads.
  • BCMath object API - BCMath now has an object-oriented API with operator overloading, which is a welcome modernisation.

Why Staying Current Matters

Features are exciting, but they are not the only reason to upgrade. The security argument is just as compelling, if not more so.

PHP follows a four-year support lifecycle for each release. Each version gets two years of active support with bug fixes and security patches, followed by two years of security-only fixes. After that, it is end of life - no more patches, no matter how critical the vulnerability.

As of early 2025, here is where the supported versions stand:

  • PHP 8.4 - Active support until late 2026, security fixes until the end of 2028
  • PHP 8.3 - Active support through 2025, security fixes until the end of 2027
  • PHP 8.2 - Security fixes only, supported until the end of 2026
  • PHP 8.1 - Security fixes only, reaching end of life on 31st December 2025

If you are running PHP 8.0 or older, you are already on an unsupported version. That means any new vulnerability discovered in your PHP runtime will not be patched. Your application might work perfectly well today, but every day you remain on an unsupported version is a day your attack surface grows.

What This Means for Laravel Projects

Laravel is our primary framework, and it has always tracked PHP versions closely. Laravel 11, the current major release, supports PHP 8.2 through 8.4. If you are planning to stay on the latest version of Laravel - and you should be - running a current PHP version is a prerequisite.

Many of PHP 8.4's features complement Laravel's existing patterns beautifully. Property hooks align well with how Eloquent already handles attribute casting and accessors. Asymmetric visibility pairs naturally with Laravel's data objects and form requests. And the improved JIT means your API responses could get that little bit faster without changing a single line of application code.

How to Check Your PHP Version

Not sure what version you are running? It takes seconds to find out. Run the following in your terminal:

php -v

Or if you want to check from within a Laravel project:

php artisan --version

If the output shows anything below 8.2, it is time to start planning an upgrade. If you are on 8.1, treat it as urgent - that version's security support runs out at the end of this year.

Planning Your Upgrade

Upgrading PHP does not have to be daunting. Here are the steps we follow with our own projects and those of our clients:

  1. Audit your dependencies - Run composer outdated and check that your packages support the target PHP version. Most well-maintained packages already support 8.4.
  2. Test in a staging environment - Never upgrade PHP directly in production. Set up a staging environment with the new version and run your test suite against it.
  3. Check for deprecation notices - PHP 8.4 deprecates several older features. Run your application and review your logs for deprecation warnings.
  4. Update your CI pipeline - Make sure your continuous integration environment reflects the PHP version you intend to run in production.
  5. Deploy with confidence - Once your tests pass and you have addressed any deprecation notices, deploy the upgrade to production.

Do Not Wait

We see it too often - teams put off PHP upgrades because everything is "working fine." But working fine today does not mean secure tomorrow. Every unsupported version is a liability, and every delayed upgrade makes the next one harder as breaking changes accumulate.

PHP 8.4 is not just a maintenance release. It is a genuine step forward for the language, with features that will make your code cleaner and your applications faster. Combined with the security benefits of staying on a supported version, there is really no good reason to delay.

If you need help upgrading your PHP version, auditing your Laravel application for compatibility, or planning a migration path from an older version, get in touch. We are always happy to help.

Ready to Start Your Project?

Get in touch with our Leeds-based team to discuss your Laravel or API development needs.