CakePHP 3.3.0 发布了,这是 3.3 分支的稳定版本,该版本提供了若干大大小小的提升改进,也弃用了一些将会在 4.0.0 被删除的功能。
升级至 3.3.0
你可以使用 Composer 升级到 CakePHP 的新版:
php composer.phar require "cakephp/cakephp:~3.3"
弃用的功能
Router::mapResources() is deprecated. Use routing scopes and $routes->resources() instead.
Router::redirect() is deprecated. Use routing scopes and $routes->redirect() instead.
Router::parseNamedParams() is deprecated. Named parameter backwards compatibility will be removed in 4.0.0
Cake\Http\Client\Response has had the following methods deprecated because they overlap with PSR7 interface methods:
statusCode() use getStatusCode() instead.
encoding() use getEncoding() instead.
header() use getHeaderLine() instead.
cookie() use getCookie() instead.
version() use getProtocolVersion() instead.
Dispatcher Filters are now deprecated. Use the new HTTP middleware features.
RequestActionTrait has been deprecated. Refactor your code to use view cells instead.
Cake\Utility\Crypto\Mcrypt engine has been deprecated as the mcrypt extension is deprecated in PHP 7.1. Use the openssl driver instead.
这份迁移指南有一个完整介绍 3.3.0 新特性和已弃用功能的列表,我们建议您升级前先阅读这份指南,下面是 3.3.0 新功能的一个简短列表:
PSR7 Middleware support has been added. This is an opt-in feature that allows you to leverage the increasing number of PSR7 middleware libraries from the broader PHP community in your CakePHP application.
A new streamlined workflow for TranslateBehavior that makes creating forms for multiple translation values easier than before.
Cake\Network\Http\Client has been moved to Cake\Http\Client. Its request and response objects now implement the PSR7 interfaces <http://www.php-fig.org/psr/psr-7/>__.
Additional support has been added for mapping complex data types. This makes it easier to work with geo-spatial types, and data that cannot be represented by strings in SQL queries.
A new JsonType was added. This new type lets you use the native JSON types available in MySQL and Postgres. In other database providers the json type will map to TEXT columns.
When entities are converted into JSON, the associated objects are no longer converted to an array first using 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.
You can now easily paginate multiple queries in a single controller action/view template.
To help you better manage cached data from the CLI environment, a shell command has been added that exposes methods for clearing cached data.
下载