What Is New in CakePHP 4.4
CakePHP 4.4 introduces a set of focused enhancements and deprecations to streamline development and prepare for the future. The table below summarizes the key updates.
| Category | Key Changes |
|---|---|
| New Features | New ResultFormatterInterface for Console, ServerRequest::getUploadedFiles() method. |
| Improvements | Better type hints, new QueryExpression::or() method, Plugin::isLoaded() check. |
| Deprecations | Legacy ResultSetInterface, Database\Log\LoggedQuery::$params, Controller::viewBuilder() as property. |
| Bug Fixes & Cleanup | Various fixes in Database, ORM, Console, and View layers. |
How does CakePHP 4.4 improve type safety?
The framework adds more precise type hints across core classes. This gives your IDE and static analysis tools better information to work with, catching potential issues earlier in development.
For instance, methods in ConnectionManager, TableRegistry, and several Query methods now have updated signatures. In practice, this means fewer surprises with return types and clearer contracts for extending core classes.
What new tools are available for database queries?
A new QueryExpression::or() method provides a fluent way to create OR conditions. It's a small but welcome addition that makes complex conditional logic in queries more readable.
// Using the new or() method
$query->where(function ($exp) {
return $exp->or([
'author_id' => 3,
'status' => 'published'
]);
});
What changes affect console output formatting?
Console commands gain flexibility with the new ResultFormatterInterface. This allows you to create custom formatters to control how command results are displayed, moving beyond the default JSON or plain text.
If you've ever wanted to output console data as XML, YAML, or a custom table format, you can now implement this interface. It's a step towards more reusable and testable console components.
Which deprecated features should I update now?
Several older interfaces and patterns are marked for removal in 5.0. The deprecated ResultSetInterface is the big one; you should type-hint against ResultSet instead.
Also, accessing Controller::viewBuilder as a property (e.g., $this->viewBuilder) is deprecated. Use the viewBuilder() *method* to get the builder instance. These changes are straightforward but important for a smooth future upgrade.
Are there new helper methods for plugin and file handling?
Yes. Plugin::isLoaded() lets you check if a plugin is loaded without needing to catch an exception. For file uploads, ServerRequest::getUploadedFiles() provides a direct way to fetch the normalized upload data array.
These are quality-of-life improvements. The plugin check is cleaner for conditional logic, and the uploaded files method offers a more object-oriented approach compared to digging into request data.
FAQ
Is CakePHP 4.4 a major feature release?
No, it's a feature release within the 4.x series. It adds some new utilities and deprecates older code to prepare for 5.0, but doesn't include breaking changes for existing, non-deprecated APIs.
What should I do about the deprecated ResultSetInterface?
Update your type hints in models and other classes from ResultSetInterface to the concrete ResultSet class. This is a simple find-and-replace operation in most codebases.
Why was accessing Controller::$viewBuilder as a property deprecated?
Using the viewBuilder() method ensures you always get a fresh instance of the builder, which is more reliable for configuration, especially in test environments or when using callbacks.
Does the new QueryExpression::or() method replace the existing orWhere()?
Not at all. It's an additional, fluent way to build conditions within an expression object. You can keep using orWhere(); this just provides another option that can be cleaner when combining multiple conditions.
How do I use the new console ResultFormatterInterface?
Create a class that implements Cake\Console\ResultFormatterInterface and define the output() method. Then, your console commands can use this formatter to control how their result data is printed. Check the CakePHP book on Result Formatters for a detailed example.