mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 04:37:46 +08:00
2.0 KiB
2.0 KiB
3.1 Upgrade Guide
- Version 3.1 mainly changes the minimum version of
PHP
to8.1
and the minimum version ofSwoole
to5.0
. - Introduced
Pest
testing framework - Added
hyperf/helper
, migratedNone namespace helper functions
fromHyperf\Utils
tohyperf/helper
. - Change the way
hyperf/config
loads multi-level configuration files to support.
syntax, e.g.,config('a.c')
Utils package changes
The helper functions in the original utils package did not have namespaces added, and might conflict with functions in other composer packages, so they were removed and replaced in 3.1.
There are two ways to handle this
- If no other packages are introduced into the application, it will cause function conflicts, so you can install
hyperf/helper
directly, and thehelper
package provides helper functions without namespaces, which is the same as the originalutils
package. - Namespaces are introduced where helper functions are called, and can be refactored using
rector
refactoring docs here 🔎
Configuration file loading changes
In 3.0, configurations existed with config file name
as the key, whereas in 3.1, hyperf/config
multi-tier config files are loaded with relative directory.Config file name
as the key.
Support for .
syntax, such as config('a.c')
.
In this regard, it is important to note that the following two cases are handled in the original project
- 3.0 project has created a subdirectory in
config/autoload
, e.g.config/autoload/sub/a.php
, the originalconfig('a')
needs to be changed toconfig('sub.a')
. - Configuration file names in 3.0 projects contain
.
, such asconfig/autoload/a.b.php
, will return the following structure when usingconfig('a')
, and if you also have aconfig/autoload/a.php
configuration file, you will also get the result after merging the configuration items.
return [
'a.php config key' => 'a.php config value',
'b' => [
'a.b.php config key' => 'a.b.php config value',
]
];