hyperf/CHANGELOG-3.0.md

6.8 KiB

v3.0.0 - TBD

  • #4238 Upgraded the minimum php version to ^8.0 for all components;

BC breaks

  • 框架移除了 @Annotation 的支持,全部使用 PHP8 原生注解 Attribute,更新前务必检查项目中,是否已经全部替换为 Attribute

可以执行以下脚本,将 Doctrine Annotations 转化为 PHP8 Attributes.

注意: 这个脚本只能在 2.2 版本下执行

composer require hyperf/code-generator
php bin/hyperf.php code:generate -D app
  • 升级模型脚本

因为模型基类增加了成员变量的类型支持,所以需要使用以下脚本,将其升级为新版本。

composer require hyperf/code-generator
php vendor/bin/regenerate-models.php $PWD/app/Model
  • 框架为类库增加了更多的类型限制,所以从 2.2 更新到 3.0 版本时,需要跑一遍静态检测。
composer analyse

Dependencies Upgrade

  • Upgraded php-amqplib/php-amqplib to ^3.1;
  • Upgraded phpstan/phpstan to ^1.0;
  • Upgraded mix/redis-subscribe to mix/redis-subscriber:^3.0
  • Upgraded psr/simple-cache to ^1.0|^2.0|^3.0
  • Upgraded monolog/monolog to ^2.7|^3.1

Added

  • #4196 Added Hyperf\Amqp\IO\IOFactory which used to create amqp io by yourself.
  • #4304 Support $suffix for trait Hyperf\Utils\Traits\StaticInstance.
  • #4400 Added $description which used to set command description easily for Hyperf\Command\Command.
  • #4277 Added Hyperf\Utils\IPReader to get local IP.
  • #4497 Added Hyperf\Coordinator\Timer which can be stopped safely.
  • #4523 Support callback conditions for Conditionable::when() and Conditionable::unless().
  • #4663 Make Hyperf\Utils\Stringable implements Stringable.
  • #4700 Support coroutine style server for socketio-server.

Optimized

  • #4147 Optimized code for nacos which you can use http://xxx.com/yyy/ instead of http://xxx.com:8848/ to connect nacos.
  • #4367 Optimized DataFormatterInterface which uses object instead of array as inputs.
  • #4547 Optimized code of Str::contains Str::startsWith and Str::endsWith based on PHP8.
  • #4596 Optimized Hyperf\Context\Context which support coroutineId for set() override() and getOrSet().
  • #4658 The method name is used as the routing path, when the path is null in route annotations.
  • #4668 Optimized class Hyperf\Utils\Str whose methods padBoth padLeft and padRight support multibyte.
  • #4678 Close all another servers when one of them closed.
  • #4688 Added SafeCaller to avoid server shutdown which caused by exceptions.
  • #4715 Adjust the order of injections for controllers to avoid inject null preferentially.

Changed

  • #4199 Changed the public property $message to protected for Hyperf\AsyncQueue\Event\Event.
  • #4214 Renamed $circularDependences to $checkCircularDependencies for Dag.
  • #4225 Split hyperf/coordinator from hyperf/utils.
  • #4269 Changed the default priority of listener to 0 from 1.
  • #4345 Renamed Hyperf\Kafka\Exception\ConnectionCLosedException to Hyperf\Kafka\Exception\ConnectionClosedException.
  • #4434 The method Hyperf\Database\Model\Builder::insertOrIgnore will be return affected count.
  • #4495 Changed the default value to null for Hyperf\DbConnection\Db::__connection().
  • #4460 Use ?? instead of ?: for $callback when using Stringable::when().
  • #4502 Use Hyperf\Engine\Channel instead of Hyperf\Coroutine\Channel in hyperf/reactive-x.
  • #4611 Changed return type to void for Hyperf\Event\Contract\ListenerInterface::process().
  • #4669 Changed all annotations which only support PHP >= 8.0.
  • #4678 Support event dispatcher for command by default.
  • #4680 Stop processes which controlled by ProcessManager when server shutdown.
  • #4848 Changed $value.timeout to $options.timeout for CircuitBreaker.

Swow Supported

  • #4756 Support hyperf/amqp.
  • #4757 Support Hyperf\Utils\Coroutine\Locker.
  • #4804 Support Hyperf\Utils\WaitGroup.
  • #4808 Replaced Swoole\Coroutine\Channel by Hyperf\Engine\Channel for all components.

Removed

  • #4199 Removed deprecated handler Hyperf\AsyncQueue\Signal\DriverStopHandler.
  • #4482 Removed deprecated Hyperf\Utils\Resource.
  • #4487 Removed log warning from cache component when the key is greater than 64 characters.
  • #4596 Removed Hyperf\Utils\Context, please use Hyperf\Context\Context instead.
  • #4623 Removed AliyunOssHook for hyperf/filesystem.
  • #4667 Removed doctrine/annotations, please use PHP8 Attributes.

Deprecated

  • Hyperf\Utils\Contracts\Arrayable will be deprecated, please use Hyperf\Contract\Arrayable instead.
  • Hyperf\AsyncQueue\Message will be deprecated, please use Hyperf\AsyncQueue\JobMessage instead.

Fixed

  • #4549 Fixed bug that PhpParser::getExprFromValue() does not support assoc array.
  • #4835 Fixed the lost description when using property $description and $signature for hyperf/command.