Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.09 KB

sys-service.md

File metadata and controls

39 lines (30 loc) · 1.09 KB

服务层Server

  • 配置
  • 调用

配置

如果需要新服务层调用方法 请在 common\servers\Application 中的 childService 添加,例如:

    /**
     * @var array
     */
    public $childService = [
        'example' => [
            'class' => 'common\servers\example\Example',
            // 子服务
            'childService' => [
                'rule' => [
                    'class' => 'common\servers\example\rule\Rule',
                ],
            ],
        ],
    ];

以上例子代表了添加了一个 example 服务及 example 的子服务 rule

调用

// 调用 example 服务里面的 index() 方法
$service = Yii::$app->servers->example->index();

// 调用 example 的子服务 rule 里面的 index() 方法
$childService = Yii::$app->servers->example->rule->index();

扩展说明:跳转地址