CakePHP 3.3 is an API compatible upgrade from 3.2. This page outlines the changes and improvements made in 3.3.
Router::mapResources()is deprecated. Use routing scopes and
Router::redirect()is deprecated. Use routing scopes and
Router::parseNamedParams()is deprecated. Named parameter backwards compatibility will be removed in 4.0.0
Cake\Http\Client\Responsehas had the following methods deprecated because they overlap with PSR-7 interface methods:
RequestActionTraithas been deprecated. Refactor your code to use View Cells instead.
Cake\\Utility\\Crypto\\Mcryptengine has been deprecated as the
mcryptextension is deprecated in PHP 7.1. Use the
While these changes are API compatible, they represent minor variances in behavior that may effect your application:
:. For example
Controller::referer()now consistently omits the application base path when generating application local URLs. Previously string URLs would have the base path prepended to them, while array URLs would not.
ErrorControllerno longer disables
Securitycomponents, as it does not extend
AppController. If you are enabling these components through events, you will need to update your code.
Entity::cleannow cleans original values, clearing them on save. This behavior was a bug as the entity’s original state should not be retained after a save, but instead reflect the new state of the entity.
In tandem with the deprecation of Dispatcher Filters, support for PSR-7 middleware has been added. Middleware is part of the new HTTP stack that is an opt-in component of CakePHP 3.3.0. By using the new HTTP stack, you can take advantage of features like:
Http\Clientand the responses your application generates.
See the Middleware chapter and Adding the new HTTP Stack to an Existing Application sections for more information and how to add the new HTTP stack to an existing application.
Cake\Network\Http\Client has been moved to
Cake\Http\Client. Its request
and response objects now implement the
PSR-7 interfaces. Several methods on
Cake\Http\Client\Response are now deprecated, see above for more
JsonTypewas added. This new type lets you use the native JSON types available in MySQL and Postgres. In other database providers the
jsontype will map to
Association::unique()was added. This method proxies the target table’s
unique()method, but ensures that association conditions are applied.
isUniquerules now apply association conditions.
toArray(). Instead, the
jsonSerialize()method will be invoked on all associated entities. This gives you more flexibility and control on which properties are exposed in JSON representations of your entities.
Table::patchEntity()will now raise an exception when an unknown association is in the ‘associated’ key.
RulesChecker::validCount()was added. This new method allows to apply rules to the number of associated records an entity has.
allowNullableNullsoption was added to the
existsInrule. This option allows rules to pass when some columns are null.
You can now paginate multiple queries in a single controller action/view template. See the Paginating Multiple Queries section for more details.
To help you better manage cached data from the CLI environment, a shell command has been added that exposes methods for clearing cached data:
// Clear one cache config bin/cake cache clear <configname> // Clear all cache configs bin/cake cache clear_all
schemaDefaultoption to false.
Validator::notEmpty()now accept a list of fields. This allows you to more concisely define the fields that are required.
StringTemplate::format() now throws an exception instead of returning
null when requested template is not found.
Collection::transpose()was added. This method allows you to tranpose the rows and columns of a matrix with equal length rows.
Acceptheader based content-type negotiation for error pages.
$methodargument added. It defaults to ‘GET’. This new parameter reduces reliance on global state, and necessary for the PSR-7 work integration to be done.
_welcomemethod invoked. They will also have the
requestedparameter set now.
Shell::err()will now apply the ‘error’ style to text. The default styling is red text.
Request::addDetector()now supports additional arguments in detectors. This allows detector callables to operate on additional parameters.