What is New in CakePHP 5.3
CakePHP 5.3 raises the minimum PHP requirement to 8.2 and adds practical enhancements across the framework. It improves pagination and sorting, supports Redis clusters for caching, introduces rate limiting middleware, and provides better tools for dependency injection, database queries, and testing. This release also includes several behavior changes for greater consistency.
Minimum PHP Requirement
CakePHP 5.3 now requires PHP 8.2 or higher. This allows the framework to use modern PHP features while ensuring better performance and security.
Pagination and Sorting Improvements
A new fluent interface makes defining sortable fields easier and more powerful.
SortableFieldsBuilderlets you map user-friendly sort keys to database fields.- Support for multi-column sorting and locked directions with
SortField. - Combined sort keys in URLs, like
?sort=title-asc.
Cache and Middleware
- Redis cache engine now supports clusters via the
clusterconfiguration option. - New
RateLimiterMiddlewareinCake\Http\Middlewarefor controlling request rates.
Database and ORM Enhancements
Query::optimizerHint()to add engine-specific hints.- New database types:
year,inet,cidr, andmacaddr. TableContainerfor dependency injection of ORM tables.strictFieldsoption in entity creation and marshalling to limit validation.- New validation rules:
ipOrRange()andexistsInNullable().
Console and Development Tools
cake plugin assets symlinksupports--relativefor relative paths.cake server --frankenphpstarts the server with FrankenPHP.Configureattribute for injecting values into constructors.
View and Helper Updates
HtmlHelper::scriptStart()andscriptEnd()wrap inline scripts properly.StringTemplate::addClassNames()for easier class management.- Improved form handling with nested checkboxes and radios by default.
Testing Improvements
- New assertions:
assertRedirectBack(),assertRedirectBackToReferer(),assertFlashMessageContains(), andassertFlashMessageContainsAt(). TestFixture::$tableAliasfor custom table aliases.
Deprecations
Query::newExpr(): UseQuery::expr()instead.Form::_execute(): Rename toprocess().$request->getParam('?'): Use$request->getQueryParams().- Direct behavior method calls on tables: Use
getBehavior()instead. EntityTrait::isEmpty(): UsehasValue().- Loading plugins without a plugin class is deprecated.
Breaking Changes and Migration Notes
| Area | Change |
|---|---|
| PHP Requirement | Must use PHP 8.2 or higher |
| Core | Use deleteConfig() instead of setting config to null in some traits |
| Query | with() now accepts arrays consistently |
| ORM | joinWith() overwrites conflicting joins |
| Validation | Validator::validate() has a new context parameter |
| View | Number helpers handle null inputs differently |
Why Upgrade to CakePHP 5.3
CakePHP 5.3 brings modern requirements and useful features that make development smoother and applications more robust. With improved sorting, caching, and testing tools, it helps teams build scalable web apps efficiently while preparing for future versions.