承接 hyperf/lazy-loader-incubator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-06