3.8 Migration Guide
CakePHP 3.8 is an API compatible upgrade from 3.7. This page outlines the changes and improvements made in 3.8.
To upgrade to 3.8.x run the following composer command:
bash
php composer.phar require --update-with-dependencies "cakephp/cakephp:3.8.*"Deprecations
Validator::allowEmptyString(),allowEmptyArray(),allowEmptyFile(),allowEmptyDate(),allowEmptyTime(), andallowEmptyDateTime()now emit a deprecation warning when using the$field, $when, $messagesignature. Instead you should use$field, $message, $when.EntityTrait::visibleProperties()is now deprecated. UsegetVisible()instead.
Behavior Changes
Cake\ORM\Table::findOrCreate()now throws aPersistenceFailedExceptionif the find fails and the entity created from$searchcontains invalid data. Previously an invalid entity would be saved.Commandclasses that have their$modelClassproperty set will now autoload that model. The manualloadModel()call with empty argument is not necessary anymore. This makes it consistent to how Shell classes worked.- The default format for
Cake\I18n\Time,FrozenTime,Date, andFrozenDateis nowyyyy-MM-dd'T'HH':'mm':'ssxxxwhich solves localization issues in danish and other european locales.
New Features
Collection
CollectionTraitnow uses thenewCollectionmethod to create clones. This allows sub-classes to have collection methods create instances of themselves instead of usingCollection.
Console
Command::executeCommand()was added. This method makes it simple to call another command from the current one.
Datasource
Cake\Datasource\ModelAwareTrait::get()can now locate model classes by fully-qualified class names, enabling you to useArticlesTable::classas a parameter toget().
Email
Email::setHeaders()andEmail::addHeaders()now allow setting multiple headers of the same name. For that the value for the particular header key in the array argument passed to above functions must be an array. e.g.$email->addHeaders(['og:tag' => ['foo', 'bar']]);
Http
Response::withCookieCollection()was added.
ORM
Cake\ORM\Locator\TableLocatorcan now locate table classes in alternative locations. You can either provide a list of namespaces to the constructor, or use theaddLocation()method.
Validation
Validator::notEmptyString(),notEmptyArray(),notEmptyFile(),notEmptyDate(),notEmptyTime(), andnotEmptyDateTime()were added. They act as compliments to theallowEmpty*methods added in 3.7.Validation::mimeType()now compares checks mime-types in a case insensitive manner.Validation::dateTime()now supports theiso8601format.
View
- Radio buttons can now customize the generated label by using the
labelkey inside a complex option definition. This key will be used instead of thelabelkey defined at the top level options.