5.4 Migration Guide
The 5.4.0 release is backwards compatible with 5.0. It adds new functionality and introduces new deprecations. Any functionality deprecated in 5.x will be removed in 6.0.0.
Upgrade Tool
The upgrade tool provides rector rules for automating some of the migration work. Run rector before updating your composer.json dependencies:
bin/cake upgrade rector --rules cakephp54 <path/to/app/src>Behavior Changes
Commands
BaseCommand::initialize()is now being triggered AFTER arguments and options have been parsed.
Console
Running bin/cake without providing a command name no longer displays the "No command provided" error message. Instead, the help command is shown directly.
The help command is now hidden from command listings (via CommandHiddenInterface). It remains accessible by running bin/cake help or bin/cake help <command>.
The CakePHP version header in help output is now only shown when the CakePHP version can be determined. When used outside a CakePHP application (where the version is reported as unknown), the header is omitted.
I18n
Number::parseFloat()now returnsnullinstead of0.0when parsing fails. This also affectsFloatTypeandDecimalTypedatabase types.
ORM
- The default eager loading strategy for
HasManyandBelongsToManyassociations has changed fromselecttosubquery. If you need the previous behavior, explicitly set'strategy' => 'select'when defining associations.
Controller
- Loading a component with the same alias as the controller's default table now triggers a warning. See Component Alias Conflicts.
Deprecations
Command Helpers
- Command helpers under the
Cake\Command\Helpernamespace have been deprecated. Instead they have been moved under theCake\Console\Helpernamespace.
Mailer
- The
Mailer::$nameproperty is unused and has been deprecated.
New Features
Core
PluginConfig::getInstalledPlugins()was added to retrieve a list of all installed plugins including flags to indicate about their scope and state.- A backwards compatible Container implementation has been added to the core. You can opt-in to use it instead of the current
league/containerimplementation by settingApp.containertocakeinside yourconfig/app.php. See Dependency Injection Container for more details.
Commands
- You can use
$this->ioand$this->argsinside your commands to access input/output and argument objects without needing to pass them down from theexecute()method. This will be the default in CakePHP 6.0 as those arguments will be removed from theexecute()method signature.
Console
- Added
ConsoleHelpHeaderProviderInterfaceto allow host applications to provide a custom header in console help output. See Customizing the Help Header.
Controller
- Added
#[RequestToDto]attribute for automatic mapping of request data to Data Transfer Objects in controller actions. See Request to DTO Mapping. - Added
unlockActions()andunlockFields()convenience methods toFormProtectionComponent. See Form Protection Component.
Database
- Added
notBetween()method forNOT BETWEENexpressions. See Query Builder. - Added
inOrNull()andnotInOrNull()methods for combiningINconditions withIS NULL. - Added
isDistinctFrom()andisNotDistinctFrom()methods for null-safe comparisons.
I18n
Number::toReadableSize()now uses decimal units (KB = 1000 bytes) by default. Binary units (KiB = 1024 bytes) can be enabled via parameter orNumber::setUseIecUnits().
ORM
- The
associatedoption innewEntity()andpatchEntity()now supports nested array format matchingcontain()syntax. See Converting Request Data into Entities.
Http
- Added PSR-13 Link implementation with
Cake\Http\Link\LinkandCake\Http\Link\LinkProviderclasses for hypermedia link support. Links added to responses are automatically emitted as HTTPLinkheaders. See Hypermedia Links.
Utility
- Added
Cake\Utility\Fs\Finderclass for fluent file discovery with pattern matching, depth control, and custom filters. AddedCake\Utility\Fs\Pathfor cross-platform path manipulation. See Filesystem Utilities. Security::encrypt()can now be configured to use longer keys with separate encryption and authentication keys that are derived from the provided key. You can setSecurity.encryptWithRawKeyto enable this behavior. See here for more details.
Collection
- Added
keys()andvalues()methods for extracting keys or re-indexing values. - Added
implode()method to concatenate elements into a string. - Added
when()andunless()methods for conditional method chaining.
View
- Added
template variable toinputContaineranderrortemplates in FormHelper. See Built-in Template Variables.