Download the PHP package liuchang103/hyperf-facade without Composer
On this page you can find all versions of the php package liuchang103/hyperf-facade. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download liuchang103/hyperf-facade
More information about liuchang103/hyperf-facade
Files in liuchang103/hyperf-facade
Download liuchang103/hyperf-facade
More information about liuchang103/hyperf-facade
Files in liuchang103/hyperf-facade
Please rate this library. Is it a good library?
Informations about the package hyperf-facade
hyperf-facade
Hyperf 门面组件,借鉴 Laravel Facade,不仅能节省依赖注入,还能在各种条件下拿到单例和容器
安装
引入包
使用
创建门面
直接返回类名,将会在 Hyperf 的容器中直接获取
下面将创建一个 Redis 门面
门面返回实例
门面静态使用
可使用在 Facade 静态调用对应方法
获取DI容器
在条件苛刻的流程中,想要拿到容器得再引入 Hyperf 工具类,在已引入的 Facade 中,即可获取
门面别名
当 Facade 需要起别名时,可用注解方式
使用别名
注:Alias 注解可作用其它类
短生命周期
以上门面代理的都会是长生命周期对象,如果想用门面使用短生命周期并且自动依赖注入,请看示例
使用门面时
同样使用静态调用
当类需要传入参数
长短生命周期测试
更好的区分应该在何时用单例模式
服务类
长生命周期
单例模式
短生命周期
使用门面时,同等 new 了一次
All versions of hyperf-facade with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.2
ext-swoole Version >=4.5
hyperf/framework Version 2.*
hyperf/di Version 2.*
ext-swoole Version >=4.5
hyperf/framework Version 2.*
hyperf/di Version 2.*
The package liuchang103/hyperf-facade contains the following files
Loading the files please wait ....