3.3 Migration Guide
- is deprecated. Use routing scopes and
$routes->resources()
instead. Router::redirect()
is deprecated. Use routing scopes and$routes->redirect()
instead.Cake\Http\Client\Response
has had the following methods deprecated because theyoverlap with PSR-7 interface methods:statusCode()
usegetStatusCode()
instead.encoding()
usegetEncoding()
instead.header()
usegetHeaderLine()
instead.cookie()
usegetCookie()
instead.version()
usegetProtocolVersion()
instead.
- Dispatcher Filters are now deprecated. Use Middlewareinstead.
RequestActionTrait
has been deprecated. Refactor your code to use instead.Cake\Utility\Crypto\Mcrypt
engine has been deprecated as themcrypt
extension is deprecated in PHP 7.1. Use theopenssl
andCake\Utility\Crypto\Openssl
instead.
Behavior Changes
While these changes are API compatible, they represent minor variances inbehavior that may effect your application:
- The default JSON encode format for Date and DateTime instances is nowISO-8601. This means that the timezone value contains a
:
.For example2015-11-06T00:00:00+03:00
- now consistently omits the application base pathwhen generating application local URLs. Previously string URLs would have thebase path prepended to them, while array URLs would not.
- The default
ErrorController
no longer disablesAuth
andSecurity
components, as it does not extendAppController
. If you are enabling thesecomponents through events, you will need to update your code. Entity::clean
now cleans original values, clearing them on save. Thisbehavior was a bug as the entity’s original state should not be retained aftera save, but instead reflect the new state of the entity.
PSR-7 Middleware Support Added
- Using middleware from plugins, and libraries outside of CakePHP.
- Leverage the same response object methods in both the responses you get from
Http\Client
and the responses your application generates. - Be able to augment the response objects emitted by error handling and assetdelivery.
See the Middleware chapter and sections for more information and how to add the new HTTP stack to an existingapplication.
Cake\Network\Http\Client
has been moved to Cake\Http\Client
. Its requestand response objects now implement thePSR-7 interfaces. Several methods onCake\Http\Client\Response
are now deprecated, see above for moreinformation.
ORM Improvements
- Additional support has been added for mapping complex data types. This makesit easier to work with geo-spatial types, and data that cannot be representedby strings in SQL queries. See theMapping Custom Datatypes to SQL Expressions for more information.
Association::unique()
was added. This method proxies the target table’sunique()
method, but ensures that association conditions are applied.isUnique
rules now apply association conditions.- When entities are converted into JSON, the associated objects are no longerconverted to an array first using
toArray()
. Instead, thejsonSerialize()
method will be invoked on all associated entities. Thisgives you more flexibility and control on which properties are exposed in JSONrepresentations of your entities. Table::newEntity()
andTable::patchEntity()
will now raise anexception when an unknown association is in the ‘associated’ key.RulesChecker::validCount()
was added. This new method allows to applyrules to the number of associated records an entity has.- The
allowNullableNulls
option was added to theexistsIn
rule. Thisoption allows rules to pass when some columns are null. - Saving translated records is now simpler. See the for more information.
Multiple Pagination Support Added
To help you better manage cached data from the CLI environment, a shell commandhas been added that exposes methods for clearing cached data:
FormHelper
- FormHelper will now automatically set the default value of fields to thedefault value defined in your database columns. You can disable this behaviorby setting option to false.
Validation
Validator::requirePresence()
,Validator::allowEmpty()
andValidator::notEmpty()
now accept a list of fields. This allows youto more concisely define the fields that are required.
Other Enhancements
Collection::transpose()
was added. This method allows you to tranpose therows and columns of a matrix with equal length rows.- The default
ErrorController
now loadsRequestHandlerComponent
toenableAccept
header based content-type negotiation for error pages.
Router::parse()
,RouteCollection::parse()
andRoute::parse()
hada$method
argument added. It defaults to ‘GET’. This new parameter reducesreliance on global state, and necessary for the PSR-7 work integration to bedone.- When building resource routes, you can now define a prefix. This is usefulwhen defining nested resources as you can create specialized controllers fornested resources.
- Dispatcher Filters are now deprecated. Use Middlewareinstead.
- Shell tasks that are invoked directly from the CLI no longer have their
_welcome
method invoked. They will also have therequested
parameterset now. Shell::err()
will now apply the ‘error’ style to text. The defaultstyling is red text.
Request::is()
andRequest::addDetector()
now supports additionalarguments in detectors. This allows detector callables to operate onadditional parameters.
- has been added to completely halt execution.