TreeviewCopyright © aleen42 all right reserved, powered by aleen42

5.2 类的加载

类的加载

php-msf类的加载采用自动加载机制,它是基于命名空间的全自动加载。

获取对象

php-msf要求所有的对象要求通过对象池的方式来获取,如下示例:

<?php
function httpLoadObject()
{
    // 获取Http Client
    $client = $this->getObject(\PG\MSF\Client\Http\Client::class);
    // 获取Task
    $client = $this->getObject(\App\Tasks\Idallloc::class);
    // 获取Model
    $client = $this->getObject(\App\Models\Demo::class, [1, 2]);
    // 获取内建对象
    $client = $this->getObject(\swoole_http_client::class, [$ip, $port]);
}

links

results matching ""

    No results matching ""