hyperf/lazy-loader-incubator
最新稳定版本:v0.1.0
Composer 安装命令:
composer require hyperf/lazy-loader-incubator
包简介
README 文档
README
中文 | English
Hyperf di 延迟加载
composer require hyperf/lazy-loader-incubator
发布配置文件
php bin/hyperf vendor:publish hyperf/lazy-loader-incubator
使用
// app/Service/UserInterface interface UserInterface { public function work(); } // app/Service/UserService class UserService implements UserInterface{ public function work() { return 'working...'; } }
// app/Controller/IndexController namespace App\Controller; use App\Service\UserInterface; use Hyperf\Di\Annotation\Inject; class IndexController { #[Inject(lazy: true)] private UserInterface $userService; public function index() { return $this->userService->work(); } }
生成延迟代理类为
// runtime/container/proxy/Hyperf_Lazy_UserService_xxx.php namespace HyperfLazy\UserService; /** * Be careful: This is a lazy proxy, not the real HyperfTest\Stub\FooService from container. * * {@inheritdoc} */ class Foo extends \App\Service\UserService { use \Hyperf\Di\LazyLoader\LazyProxyTrait; const PROXY_TARGET = 'HyperfTest\\Stub\\FooService'; public function work() { return $this->__call(__FUNCTION__, func_get_args()); } }
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-06